57 lines
5.3 KiB
JavaScript
57 lines
5.3 KiB
JavaScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import assert from 'node:assert/strict';
|
|
import {createHash} from 'node:crypto';
|
|
import {execFileSync} from 'node:child_process';
|
|
import {nativeSystemTexts} from '../src/core/engines/purge-strategy.mjs';
|
|
|
|
// Offline evidence checks only; never imports the original plugin or creates
|
|
// a Runtime, Provider, native process, network listener or model request.
|
|
const root=path.resolve('docs/original-purge-load-evidence'),sha=value=>createHash('sha256').update(value).digest('hex');
|
|
const inside=relative=>{const file=path.resolve(root,relative);assert.ok(file.startsWith(root+path.sep));return file;};
|
|
const raw=fs.readFileSync(inside('manifest.json')),manifest=JSON.parse(raw),read=relative=>JSON.parse(fs.readFileSync(inside(relative)));
|
|
assert.equal(manifest.schemaVersion,1);assert.equal(manifest.realModelRequests,0);assert.equal(manifest.productionStrategyImplemented,false);
|
|
const seen=new Set();let bytes=0;
|
|
for(const entry of manifest.entries){assert.ok(!seen.has(entry.path));seen.add(entry.path);const data=fs.readFileSync(inside(entry.path));
|
|
assert.equal(data.length,entry.bytes,entry.path);assert.equal(sha(data),entry.sha256,entry.path);bytes+=data.length;}
|
|
assert.equal(seen.size,manifest.count);assert.equal(bytes,manifest.bytes);
|
|
for(const input of manifest.sourceInputs){
|
|
assert.match(input.path,/^scripts\/[a-z-]+\.mjs$/);
|
|
const blob=execFileSync('git',['show',manifest.sourceCommit+':'+input.path],{windowsHide:true,maxBuffer:1024*1024});
|
|
assert.equal(sha(blob),input.gitBlobSha256);assert.equal(sha(fs.readFileSync(inside(input.snapshot))),input.sha256);
|
|
}
|
|
for(const input of manifest.upstreamInputs){const data=fs.readFileSync(inside(input.snapshot));assert.equal(sha(data),input.sha256);assert.equal(data.length,input.bytes);}
|
|
assert.equal(manifest.upstreamInputs.length,60);
|
|
const final=read(manifest.final.result),modelInputs=read(manifest.final.modelInputs);
|
|
assert.equal(final.passed,true);assert.equal(final.realModelRequests,0);assert.equal(final.productionStrategyImplemented,false);
|
|
assert.equal(final.upstreamPatchInstalled,false);assert.equal(final.nativeAddonIsolation,'not_an_os_sandbox');assert.equal(final.closure.length,31);
|
|
assert.deepEqual(final.externals,['@deepseek-ai/dsh-llm']);
|
|
for(const key of ['autoApplyOnStart','autoUpdateOnStart','autoRevertOnMissing','autoRetry','autoContinue','hooksDenyBypass'])assert.equal(final.config[key],false);
|
|
assert.deepEqual(final.results.map(value=>value.scenario),['completed','failed-no-retry','blocked-purge-apply','host-denied-tool']);
|
|
assert.deepEqual(final.results.map(value=>value.requests),[1,1,2,2]);assert.deepEqual(final.results.map(value=>value.toolCalls),[0,0,0,1]);
|
|
const nativeInputs=new Map(manifest.loadedModuleInputs.map(input=>[input.path,input]));let moduleRecords=0;
|
|
for(const result of final.results){
|
|
assert.equal(result.ready.originalApplyCalled,true);assert.equal(result.ready.originalEntryLoaded,true);assert.equal(result.ready.loaded.length,31);
|
|
assert.deepEqual(result.ready.blockedTools,['purge_apply','purge_revert','purge_status']);assert.deepEqual(result.ready.denied,{read:true,write:true,child:true});
|
|
assert.equal(result.processReport.cleanup.rootExited,true);assert.equal(result.processReport.cleanup.treeConfirmed,true);assert.deepEqual(result.processReport.cleanup.remainingProcesses,[]);
|
|
if(result.scenario==='completed'){
|
|
assert.equal(result.error,null);assert.equal(result.processReport.status,'closed');assert.equal(result.processReport.cleanup.exit.code,0);
|
|
assert.equal(result.processReport.cleanup.forced,false);assert.deepEqual(result.brokerRejections.map(value=>[value.name,value.status]),
|
|
[['unowned-auth',409],['outside-runtime',409],['wrong-file-identity',409]]);
|
|
}else assert.ok(result.error);
|
|
assert.ok(result.durabilityReceipts.length>=2);assert.equal(result.moduleInputs.length,335);
|
|
for(const flush of result.durabilityReceipts){assert.equal(flush.operation,'actual-parent-fsync');assert.match(flush.sha256,/^[a-f0-9]{64}$/);assert.ok(!flush.path.split(/[\\/]/).includes('..'));}
|
|
for(const input of result.moduleInputs){const original=nativeInputs.get(input.path);assert.equal(original.sha256,input.sha256);
|
|
const data=fs.readFileSync(inside(original.snapshot));assert.equal(sha(data),input.sha256);assert.equal(data.length,input.bytes);
|
|
if(input.sourceSha256)assert.equal(input.sourceSha256,input.sha256);moduleRecords++;}
|
|
}
|
|
assert.equal(modelInputs.length,6);for(const {input} of modelInputs)assert.equal(nativeSystemTexts(input).join('\n').split(final.config.postPrompt).length-1,1);
|
|
for(const receipt of manifest.developmentReceipts){
|
|
const result=read(receipt.result);if(receipt.classification==='insufficient_exit_assertions'){
|
|
assert.equal(result.passed,true);assert.equal(result.results[0].processReport.status,'failed');assert.notEqual(result.results[0].processReport.cleanup.exit.code,0);
|
|
}
|
|
}
|
|
console.log(JSON.stringify({passed:true,sourceCommit:manifest.sourceCommit,manifestSha256:sha(raw),files:seen.size,bytes,upstreamFiles:60,
|
|
originalModules:31,moduleRecords,observedModulePaths:nativeInputs.size,scenarios:4,ownedBridgeCalls:6,realModelRequests:0,
|
|
scope:'Offline byte/source/actual-load/exit/external-denial checks only. Native OS isolation, production strategy and original Purge benefit remain incomplete.'}));
|