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 / transport.mjs

41 lines · 3185 bytes Raw Blame History
1import fs from 'node:fs';
2import {spawn,spawnSync} from 'node:child_process';
3import assert from 'node:assert/strict';
4import {intent,discovery} from './fixtures.mjs';
5const exe=process.cwd()+'/target/L558/hardware-map';
6const rows=[];
7async function fragmented(name,parts,expected) {
8 const c=spawn(exe,[],{stdio:['pipe','pipe','pipe','pipe']});
9 let out=Buffer.alloc(0),err=Buffer.alloc(0);
10 c.stdout.on('data',b=>out=Buffer.concat([out,b]));c.stderr.on('data',b=>err=Buffer.concat([err,b]));
11 c.stdin.on('error',e=>{if(e.code!=='EPIPE')throw e;});c.stdio[3].on('error',e=>{if(e.code!=='EPIPE')throw e;});
12 const result=new Promise((resolve,reject)=>{c.on('error',reject);c.on('close',(code,signal)=>resolve({code,signal}));});
13 const timer=setTimeout(()=>c.kill('SIGKILL'),3000);
14 const r=intent(4),d=discovery();
15 for(let i=0;i<96;i+=parts){c.stdin.write(r.subarray(i,i+parts));c.stdio[3].write(d.subarray(i,i+parts));await new Promise(ok=>setImmediate(ok));}
16 c.stdin.end();c.stdio[3].end();
17 const status=await result;clearTimeout(timer);assert.equal(status.code,expected,err.toString());assert.equal(status.signal,null);
18 assert.equal(JSON.parse(out).capability,'hw_dma_map');assert.equal(err.length,0);
19 rows.push({name,exit:status.code,stdout_bytes:out.length});
20}
21for(const size of [1,2,7,31])await fragmented('fragmented-'+size,size,0);
22const path='target/L558/discovery.bin';fs.writeFileSync(path,discovery());
23let fd=fs.openSync(path,'r');
24const run=(name,args,expected)=>{const x=spawnSync(args[0],args.slice(1),{input:intent(),stdio:['pipe','pipe','pipe',fd],timeout:3000});assert.equal(x.error,undefined);assert.equal(x.status,expected,x.stderr?.toString());rows.push({name,exit:x.status,stdout_bytes:x.stdout.length});return x;};
25// Absence of host channel cannot be repaired with model bytes.
26const nohost=spawnSync(exe,[],{input:intent(),timeout:3000});assert.equal(nohost.status,20);assert.equal(nohost.stdout.length,0);rows.push({name:'missing-trusted-channel',exit:nohost.status});
27fs.closeSync(fd);fd=fs.openSync(path,'r');
28// Inject failures into this child only. No signal or syscall reaches any other process.
29run('stdin-EINTR',['strace','-qq','-o','target/L558/eintr.trace','-e','inject=read:error=EINTR:when=1',exe],0);
30fs.closeSync(fd);fd=fs.openSync(path,'r');
31run('stdin-EIO',['strace','-qq','-o','target/L558/eio.trace','-e','inject=read:error=EIO:when=1',exe],20);
32fs.closeSync(fd);fd=fs.openSync(path,'r');
33run('stdout-EIO',['strace','-qq','-o','target/L558/write-eio.trace','-e','inject=write:error=EIO:when=1',exe],29);
34fs.closeSync(fd);fd=fs.openSync(path,'r');
35run('normal-syscall-trace',['strace','-qq','-o','qualification/evidence/L558/native-syscalls.log',exe],0);
36fs.closeSync(fd);
37const trace=fs.readFileSync('qualification/evidence/L558/native-syscalls.log','utf8');
38const syscalls=[...trace.matchAll(/^([a-z0-9_]+)\(/gm)].map(m=>m[1]);
39assert(syscalls.every(s=>['execve','read','write','exit'].includes(s)),syscalls.join(','));
40fs.writeFileSync('qualification/evidence/L558/transport.json',JSON.stringify({cases:rows,observed_syscalls:[...new Set(syscalls)]},null,2)+'\n');
41console.log(`PASS ${rows.length} native transport/fault checks`);