interplane.Get Omega
Read in your language

interplane-mv

INTERPLANE: open interoperability protocol between AI models and agent runtimes. Models express intent. Runtimes retain authority.

Brought by drakestapleton

branch main Branches Tags History

interplane-mv / tests / hardware / mutants.mjs

30 lines · 1844 bytes Raw Blame History
1import fs from 'node:fs';
2import {spawnSync} from 'node:child_process';
3import {createHash} from 'node:crypto';
4import assert from 'node:assert/strict';
5const source=fs.readFileSync('omega/hardware/map.om','utf8');
6const mutants=[
7 ['discovery-binding','if ne get r add i 32 get d add i 32\nret 24\nend',''],
8 ['dma-isolation','if ne get d 14 3\nret 28\nend',''],
9 ['timer-range','gt val 2147483647','gt val 18446744073709551615'],
10 ['coherency','if and eq get d 14 0 eq get d 15 2\nret 25\nend',''],
11 ['vendor','ne get d 7 0','ne uchar 0 0'],
12];
13const results=[];
14for(const [name,from,to] of mutants) {
15 assert.equal(source.split(from).length,2,`unique mutant site ${name}`);
16 const input=source.replace(from,to);
17 const p='target/L558/mutant-'+name;
18 fs.writeFileSync(p+'.om',input);
19 const c=spawnSync('quiet-build',['target/L558/omc'],{input,timeout:30000});
20 assert.equal(c.status,0,`mutant must compile: ${name} ${c.stderr}`);
21 assert.equal(c.stdout.subarray(0,4).toString('hex'),'7f454c46');
22 fs.writeFileSync(p,c.stdout,{mode:0o755});
23 const test=spawnSync('node',['tests/hardware/acceptance.mjs',process.cwd()+'/'+p],{env:{...process.env,HW_EVIDENCE:process.cwd()+'/target/L558/mutant-evidence-'+name},timeout:30000});
24 fs.writeFileSync(`qualification/evidence/L558/mutant-${name}.log`,test.stdout.toString()+test.stderr.toString());
25 assert.equal(test.status,1,`behavior suite must reject compiled ${name}`);
26 assert.match(test.stderr.toString(),/AssertionError/);
27 results.push({name,compile_exit:c.status,behavior_exit:test.status,source_sha256:createHash('sha256').update(input).digest('hex'),executable_sha256:createHash('sha256').update(c.stdout).digest('hex')});
28}
29fs.writeFileSync('qualification/evidence/L558/mutants.json',JSON.stringify(results,null,2)+'\n');
30console.log(`PASS ${results.length} compiled mutants detected`);