Files
Agent-Workbench/docs/project-cache-f-interim-evidence/0122-record-cache-formal-native.mjs
T
2026-11-01 04:26:24 +08:00

17 lines
1.9 KiB
JavaScript

import fs from 'node:fs';
import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
import { publicSnapshot, compareOriginalState } from './cache-f-state.mjs';
import { HostController } from '../src/core/desktop/host-controller.mjs';
const read=file=>JSON.parse(fs.readFileSync(file,'utf8'));
const deployed=read('.qa/cache-f-formal-verify.json');assert.equal(deployed.success,true);
const current=await publicSnapshot('http://127.0.0.1:4318',deployed.dataRoot),retained=compareOriginalState(read(read('.qa/cache-f-formal-baseline-location.json').before),current);
assert.equal(current.version,'1.19.0');assert.equal(current.pid,36552);assert.equal(current.runtimeRoot,deployed.candidate);
const controller=new HostController({appRoot:deployed.candidate,dataRoot:deployed.dataRoot,port:4318,nodePath:process.execPath});
assert.ok(await controller.connect());const status=await controller.status();assert.equal(status.desktopWindows.count,1);assert.equal(status.activity.active,false);
const observed=read('.qa/cache-native-after/observed.json');assert.equal(observed.success,true);assert.equal(observed.versionObserved,'1.19.0');
for(const row of observed.files){const bytes=fs.readFileSync(row.path);assert.equal(bytes.length,row.bytes);assert.equal(createHash('sha256').update(bytes).digest('hex'),row.sha256);}
const result={success:true,version:current.version,at:new Date().toISOString(),current,retained,hostPid:36552,currentProviderPreserved:true,desktopWindows:status.desktopWindows,observed,realModelRequests:0,
scope:'Actual formal native window inspected via Windows sky. User project and existing connection observed, no task or configuration changes; all stored rows, session exports and original artifacts remain exact.'};
fs.writeFileSync('.qa/cache-f-formal-native.json',JSON.stringify(result,null,2)+'\n',{flag:'wx'});console.log(JSON.stringify({success:true,version:current.version,nativeWindows:1,originalStateRetained:true}));