Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienos.com/blob/main/om/allen-scene/test-parity.cjs # aienos.com Source of www.aienos.com, served from my own hardware Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienos.com / om / allen-scene / test-parity.cjs` 44 lines ยท 3262 bytes Raw Blame History 1 /* Targeted renderer ABI/parity test; not an iMac hardware qualification. */ 2 'use strict'; 3 const fs=require('node:fs'), assert=require('node:assert/strict'); 4 const {execFileSync}=require('node:child_process'); 5 (async () => { 6 const oracle=process.argv[2], wasm=process.argv[3]||'public/allen/scene.wasm', original=process.argv[4]; 7 if(!oracle || !original) throw new Error('usage: node om/allen-scene/test-parity.cjs /path/to/native-oracle wasm /path/to/original-ui-oracle'); 8 const module=await WebAssembly.compile(fs.readFileSync(wasm)); 9 assert.deepEqual(WebAssembly.Module.imports(module),[],'native WASM must have no imports'); 10 const {exports:ex}=await WebAssembly.instantiate(module,{}); 11 assert.equal(ex.scene_init(63,400,0),0,'undersized canvas refusal'); 12 assert.equal(ex.scene_init(1920,1920,0),0,'pixel capacity refusal'); 13 assert.equal(ex.scene_view(-1,0,80000),0,'uninitialized/invalid camera refusal'); 14 const cases=[[1,0,0,0],[1,600,0,0],[1,2000,0,0],[1,3200,0,0],[1,4192,0,0],[1,5104,0,0],[1,7216,0,0],[2,8000,0,0],[2,12000,0,0],[2,12608,0,0],[2,16512,0,0],[0,17600,0,1],[0,16512,0,2],[0,16512,1,0]]; 15 for(const [kind,target,compact,variant] of cases) { 16 assert.equal(ex.scene_init(640,400,compact),1); 17 ex.scene_enter(kind); 18 if(variant===2) assert.equal(ex.scene_view(`119000000`,-`71000000`,60000),1); 19 for(let t=0;t<=target;t+=16) { 20 if(variant===1 && t===16000) ex.scene_key(t); 21 if(variant===1 && t===17008) ex.scene_word(t); 22 ex.scene_step(t,variant===1?(t<16000?0:t<17008?1:3):0,variant===1?128:0); 23 } 24 ex.scene_step(target,variant===1?3:0,variant===1?128:0); 25 ex.scene_draw(variant===1?256:0,variant===1?128:0); 26 if(variant===1) ex.scene_glyph(65,300,300,200); 27 const observed=Buffer.from(ex.memory.buffer,ex.scene_pixels(),640*400*4); 28 const expected=execFileSync(oracle,[kind,target,compact,variant].map(String),{maxBuffer:640*400*4+1024}); 29 assert.equal(expected.length,observed.length,'oracle cannot silently omit pixels'); 30 assert.equal(observed.compare(expected),0,`RGBA mismatch kind=${kind} t=${target} compact=${compact} variant=${variant}`); 31 if(!compact && !variant && ((kind===1 && target<4200) || (kind===2 && target<15300))) { 32 const originalFrame=execFileSync(original,[kind,target].map(String),{maxBuffer:640*400*4+1024}); 33 assert.equal(observed.compare(originalFrame),0,`ORIGINAL allen_ui.c mismatch kind=${kind} t=${target}`); 34 console.log(`Independent original allen_ui.c RGB parity kind=${kind} time=${target} (opaque alpha normalized)`); 35 } 36 const mutant=Buffer.from(observed);mutant[0]^=1; 37 assert.notEqual(mutant.compare(expected),0,'wrong-pixel negative control must differ'); 38 console.log(`RGBA byte parity kind=${kind} time=${target} compact=${compact} variant=${variant}`); 39 } 40 const ptr=ex.scene_audio(11360*48,45120),pcm=Buffer.from(ex.memory.buffer,ptr,45120*4); 41 assert.equal(pcm.compare(execFileSync(oracle,['audio'],{maxBuffer:45120*4+1024})),0,'native chirp PCM byte mismatch'); 42 assert.equal(ex.scene_audio(0,48001),0,'audio capacity refusal'); 43 console.log('PCM byte parity; invalid sizes/camera/audio refused; wrong-pixel control rejected'); 44 })().catch(error => {console.error(error);process.exitCode=1;});