fix(ci): make historical replay suites self-contained
This commit is contained in:
@@ -1,26 +1,14 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { engineCanonicalDigest } from '../src/shared/contracts/engines.mjs';
|
||||
import { nativeMessagesToChat } from '../src/shared/contracts/engine-execution.mjs';
|
||||
import { engineHistoryGroups,engineResultView,engineContextIndex,engineContextView } from '../src/shared/contracts/engine-context.mjs';
|
||||
import { replayFixtureJson } from '../scripts/verify-replay-fixtures.mjs';
|
||||
|
||||
const root=path.resolve('docs/live-model-purge-1.24-evidence'),read=file=>JSON.parse(fs.readFileSync(file,'utf8'));
|
||||
const manifest=read(path.join(root,'manifest.json'));
|
||||
const artifacts=new Map(manifest.artifacts.map(x=>[x.id,x]));
|
||||
function replay(name){
|
||||
const result=read(path.join(root,'samples',name,'result.json'));
|
||||
const report=read(path.join(root,'samples',name,'engine-'+result.engineRuns[0].id+'.json'));
|
||||
const session=read(path.join(root,'samples',name,'original-child-session.json'));
|
||||
const input=report.native.bridgeRequests.filter(x=>x.route==='/model').at(-1).data;
|
||||
const messages=nativeMessagesToChat(input),evidence=report.calls.map(call=>({
|
||||
callId:call.sourceCallId,name:call.name,argumentsSha256:call.argumentsSha256,
|
||||
content:fs.readFileSync(path.join(root,artifacts.get(call.outputArtifactId).file),'utf8'),
|
||||
artifactId:call.outputArtifactId,sha256:call.outputSha256,invocationId:call.invocationId,state:call.status,requiresVerification:false,
|
||||
}));
|
||||
const {input,config,evidence}=replayFixtureJson('engine-context/'+name+'.json');
|
||||
const messages=nativeMessagesToChat(input);
|
||||
const index=engineContextIndex(messages,evidence,{artifact_id:'original-native-input',sha256:engineCanonicalDigest(input)});
|
||||
const config={...session.execution.run.model,modelRouting:session.execution.run.model.routing,maxOutputTokens:input.maxTokens};
|
||||
const projected=engineContextView(messages,input.tools.map(x=>({type:'function',function:x})),config,index,{id:'original-index',sha256:engineCanonicalDigest(index)});
|
||||
return {input,messages,index,config,projected,evidence};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user