25 lines
2.3 KiB
JavaScript
25 lines
2.3 KiB
JavaScript
import fs from 'node:fs';
|
|
import assert from 'node:assert/strict';
|
|
import { publicSnapshot, compareOriginalState } from './protocol-f-state.mjs';
|
|
import { digest } from './desktop-f-state.mjs';
|
|
const pointer=JSON.parse(fs.readFileSync('C:/Users/wangy/AppData/Local/Programs/AgentWorkbench/current.json'));
|
|
const before=await publicSnapshot('http://127.0.0.1:4318',fs.realpathSync.native(pointer.dataRoot));
|
|
assert.equal(before.version,'1.16.0');
|
|
fs.writeFileSync('.qa/protocol-f-preflight-state.json',JSON.stringify(before,null,2)+'\n',{flag:'wx'});
|
|
const expected=structuredClone(before); expected.version='1.17.0';
|
|
for(const c of expected.modelCenter.connections) Object.assign(c,{streaming:false,capabilitySchema:1,
|
|
capabilityDeclarations:{text:'supported',tools:'supported',streaming:'unknown',vision:'unknown',audio:'unknown'},
|
|
capabilities:{text:'protocol_declared',tools:'protocol_declared',streaming:'unknown',vision:'unknown',audio:'unknown'}});
|
|
expected.modelCenterSha256=digest(expected.modelCenter);
|
|
assert.doesNotThrow(()=>compareOriginalState(before,expected));
|
|
const cases=['Only the documented public capability read defaults are accepted'];
|
|
for(const [name,change] of [
|
|
['Changed original connection revision is rejected',x=>x.modelCenter.connections[0].revision++],
|
|
['Changed original connection model is rejected',x=>x.modelCenter.connections[0].model+='-different'],
|
|
['An extra stored row is rejected',x=>x.database.tables.records.count++],
|
|
['Changed original artifact bytes are rejected',x=>x.persistent.artifacts[0].sha256='0'.repeat(64)],
|
|
['Forged verified tools are rejected',x=>x.modelCenter.connections[0].capabilities.tools='verified'],
|
|
]) { const changed=structuredClone(expected); change(changed); assert.throws(()=>compareOriginalState(before,changed)); cases.push(name); }
|
|
const result={success:true,cases,realModelRequests:0,scope:'Owned comparison mutations only; original formal state was read without configuration, task, credential or artifact writes.'};
|
|
fs.writeFileSync('.qa/protocol-f-state-comparator-validation.json',JSON.stringify(result,null,2)+'\n',{flag:'wx'}); console.log(JSON.stringify({success:true,cases:cases.length,projects:before.projects,sessions:before.database.sessionIds.length,records:before.database.tables.records.count,events:before.database.tables.events.count}));
|