diff --git a/scripts/check_console_puzzle.mjs b/scripts/check_console_puzzle.mjs index abc3cb33e..03db0e082 100644 --- a/scripts/check_console_puzzle.mjs +++ b/scripts/check_console_puzzle.mjs @@ -1,47 +1,134 @@ // SPDX-License-Identifier: AGPL-3.0-only -// Fail-closed source compatibility gate for the ONE integrated release branch. -// Contract self-tests can run on every PR. --release requires THREE owners' -// exact real-producer/consumer socket and refuses synthetic-only readiness. +// Milestone A: fail-closed STATIC convergence gate for the one approved +// /preview/ -> JUCE WebView2 -> native ChannelId PCM product. +// This deliberately does not certify a Windows executable or physical sound. +// CTest, screenshot parity, packaged SHA and hardware FAT are separate gates. import {readFileSync} from 'node:fs'; import {resolve} from 'node:path'; +import {fileURLToPath} from 'node:url'; import {execFileSync} from 'node:child_process'; -const files={ - native:'src/ConsoleLiveBridgeV6.h', - dispatcher:'src/Main.cpp', - gui:'web/mixer-layout.js', - guiTest:'tests/operator_console_v6_smoke.py', - fat:'scripts/console_v6_fat_gate.mjs', - fatTest:'tests/console_v6_fat_gate_test.mjs' -}; -const release=process.argv.includes('--release'); -const read=path=>{try{return readFileSync(resolve(path),'utf8')}catch{return ''}}; -const data=Object.fromEntries(Object.entries(files).map(([k,p])=>[k,read(p)])); -const checks=[ - ['ENGINE real device pin masks',/setProperty\("enabledInputs"/.test(data.native)&&/setProperty\("enabledOutputs"/.test(data.native),'ENGINE #266: publish enabledInputs and enabledOutputs from active device pin mask'], - ['ENGINE actual accepted stable ChannelId roster',!/graph->setProperty\("channels",juce::var\(juce::Array\{\}\)\)/.test(data.native)&&/setProperty\("channels"/.test(data.native),'ENGINE #266: serialize real accepted roster, not empty array'], - ['ENGINE universal processing admitted',!/setProperty\("productionCallbackLive",false\)/.test(data.native),'ENGINE #266: actual callback full fidelity must gate productionCallbackLive dynamically'], - ['ENGINE real ConsoleIntent dispatch',!/consoleBridge_\.rejectUnsupportedIntent\(args,snap\)/.test(data.dispatcher),'ENGINE #266: route valid intents to prepared accepted native graph, preserve rollback'], - ['GUI native ACK and snapshot listeners',/arMixConsoleAck/.test(data.gui)&&/arMixConsoleSnapshot/.test(data.gui),'GUI #271: consume real native ACK and snapshot'], - ['GUI fixture from one canonical source',/console-v6\/fixtures\.json/.test(data.guiTest),'GUI #271: use shared fixture file, remove standalone MAIN/BUS-FX fake ids'], - ['FAT checks native device endpoints and pin masks',/enabledInputs/.test(data.fat)&&/enabledOutputs/.test(data.fat),'FAT #270: validate native producer enabled pins, not hand-authored fantasy fields'], - ['FAT fixture from one canonical source',/console-v6\/fixtures\.json/.test(data.fatTest),'FAT #270: use the SAME shared fixture as GUI tests, not duplicate schema'], -]; -execFileSync(process.execPath,['--test','tests/console_v6_puzzle_seam_test.mjs'],{stdio:'inherit'}); -const blockers=checks.filter(x=>!x[1]); -for(const [name,pass,fix] of checks) - console.log((pass?'[MATCH] ':'[MISMATCH] ')+name+(pass?'':' -> '+fix)); -if(release){ - if(blockers.length){ - console.error('RELEASE PUZZLE GATE BLOCKED: '+blockers.length+' missing native/GUI/FAT sockets. No partial EXE/UAT.'); - process.exitCode=1; - }else console.log('RELEASE SOURCE SOCKET MATCH: static preflight only; native CTest, UI Playwright and independent physical FAT still required.'); -}else{ - console.log('G0 contract self-tests complete; --release will block until all three real owner branches match.'); -} -// Windows RELEASE must embed EXACT current /preview/ with approved PNG controls. -// Intent/snapshot schema alone is not a finished GUI; reject alternate shells. -if(release){ - try{execFileSync(process.execPath,['scripts/check_approved_native_gui_release.mjs'],{stdio:'inherit'});} - catch(e){console.error('RELEASE BLOCKED: Windows GUI is not identical to approved /preview/');process.exitCode=1;} +export const PATHS=Object.freeze({ + cmake:'CMakeLists.txt', + entry:'src/Main.cpp', + engine:'src/LiveAudioEngine.h', + nativeG0:'src/ApprovedConsoleNativeTransportV6.h', + nativeV8:'src/ConsoleLiveBridgeV6.h', + projection:'src/ApprovedNativeV8Projection.h', + renderOwner:'engine/core/NativeRenderAuthority.h', + gui:'web/approved-native-bridge.js', + protocol:'web/approved-native-contract.js', + assembler:'scripts/build_approved_native_gui.py', + pages:'scripts/build_pages.py', + nativeTests:'tests/console_native_integration_test.cpp', + uiTests:'tests/approved_native_m2_contract.test.cjs', + fat:'scripts/verify_native_windows_artifact.ps1', + windows:'.github/workflows/p1-windows.yml' +}); +export function collectSources(root=resolve('.')) { + const out={}; + for(const [key,path] of Object.entries(PATHS)) { + try {out[key]=readFileSync(resolve(root,path),'utf8');} + catch {out[key]='';} + } + return out; +} +// Result ids are stable so negative regression tests never rely on log wording. +// "release" checks are necessary source evidence, NOT sufficient audio proof. +export function inspectMilestoneA(s) { + const has=(key,pattern)=>pattern.test(s[key]||''); + const yes=(id,ok,reason,release=false)=>({id,pass:Boolean(ok),reason,release}); + const approved=has('cmake',/build_approved_native_gui\.py/) && + has('cmake',/ARMIX_APPROVED_GUI_DIR/) && + has('assembler',/build_pages\.py/) && + has('pages',/APPROVED_SINGLE_GUI/); + const resource=has('entry',/ApprovedGuiResources\.h/) && + has('entry',/resolveApprovedGuiResource/) && + has('entry',/withResourceProvider\s*\(\s*assetFor\s*\)/); + const socket=['arMixConsoleSubscribe','arMixConsoleIntent', + 'arMixConsoleSnapshot','arMixConsoleAck']; + const nativeWire=socket.every(name=>(s.entry||'').includes(name)); + const guiWire=socket.every(name=>((s.gui||'')+'\n'+(s.protocol||'')).includes(name)); + const oldEmbedded=/juce_add_binary_data\(ARMixAssets\s+SOURCES\s*web\//.test(s.cmake||'') || + /web\/console-native\.(?:html|css|js)/.test(s.cmake||'') || + /BinaryData::(?:consolenative_html|index_html)/.test(s.entry||''); + const controls=has('gui',/consumeField/) && has('gui',/consumeWire/) && + has('gui',/onSnapshot/) && has('gui',/onAck/) && + has('protocol',/readbackProvesIntent/) && + has('protocol',/baseGraphRevision/) && + has('protocol',/baseRosterRevision/); + const currentG0=has('nativeG0',/productionCallbackLive",\s*false/) && + has('nativeG0',/supportedOps",\s*juce::var\s*\(\s*juce::Array/); + const tests=has('windows',/ctest --test-dir build -C Release --output-on-failure/) && + has('windows',/check_approved_native_gui_release\.mjs/) && + has('windows',/verify_native_windows_artifact\.ps1/); + const baseline=[ + yes('single-approved-pages-source',approved, + 'CMake, Pages and native assembly must use the sole approved /preview/'), + yes('juce-serves-approved-resources',resource, + 'The JUCE WebView must dispatch generated approved GUI resources'), + yes('no-retired-console-renderer',!oldEmbedded, + 'Do not compile web/index or web/console-native as another mixer'), + yes('native-four-event-socket',nativeWire, + 'Main.cpp must carry Subscribe/Intent/Snapshot/Ack'), + yes('gui-four-event-consumer',guiWire&&controls, + 'Existing /preview/ adapter must consume real native ACK/readback'), + yes('canonical-uint64-protocol',has('protocol',/BigInt/) && + has('protocol',/normalizeSnapshot/) && + has('protocol',/createController/), + 'Stable native ChannelId/EdgeId, not JS Number or optimistic UI'), + yes('ci-keeps-native-qualification',tests, + 'One Windows pipeline must build, CTest, verify approved GUI and package') + ]; + const producerJoined=has('entry',/ConsoleLiveBridgeV6\.h/) && + has('nativeV8',/PuzzleV8Wire/) && + has('projection',/mainChannelId/) && + has('projection',/processingFormat/); + const dispatched=has('entry',/processNativeBusIntent|processConsoleIntent|dispatchConsoleIntent/) && + !has('entry',/native_console_m2::reject\s*\(\s*args,\s*accepted\s*\)/); + const pcmReadback=has('engine',/nativeChannelIdPcmActive|acceptedChannelId/) && + has('engine',/audioDeviceIOCallbackWithContext/) && + has('nativeV8',/nativeBus|acceptedRouting/); + const integration=[ + yes('real-v8-producer-installed',producerJoined, + 'ENGINE #266 must connect its real accepted native V8 graph producer to Main.cpp',true), + yes('intent-dispatch-not-g0-rejection',dispatched, + 'Valid admitted native intents must execute on the ONE engine; G0 blanket reject cannot ship',true), + yes('actual-channelid-callback-readback',pcmReadback, + 'One installed audio callback must expose native ChannelId PCM and true accepted graph state',true), + yes('native-graph-impulse-regression',has('nativeTests',/DynamicAcceptedSession/) && + has('nativeTests',/render\(/) && has('nativeTests',/ack/) && + has('nativeTests',/projectAcceptedConsoleV6/), + 'Keep native PCM and graph ACK regression in CTest; synthetic Pages data is insufficient',true), + yes('fat-verified-packaging-wired',has('fat',/approved.gui|approved.gui.manifest|approved-gui|preview/i) && + has('windows',/package_native_windows\.ps1/) && + has('windows',/verify_native_windows_artifact\.ps1/), + 'Exact approved GUI bundle, Windows EXE and FAT package verifier must be wired',true) + ]; + // Baseline G0 is ALLOWED during development, never advertised as a product. + // Kept separately to prevent either fake LIVE or spurious failures on main. + return {baseline,integration,g0Truthful:currentG0}; +} +async function cli() { + const release=process.argv.includes('--release'); + execFileSync(process.execPath,['--test','tests/console_v6_puzzle_seam_test.mjs', + 'tests/milestone_a_native_contract_test.mjs'],{stdio:'inherit'}); + const report=inspectMilestoneA(collectSources()); + const selected=release?[...report.baseline,...report.integration]:report.baseline; + for(const x of selected) + console.log((x.pass?'[MATCH] ':'[BLOCKED] ')+x.id+(x.pass?'':' — '+x.reason)); + const blocked=selected.filter(x=>!x.pass); + if(blocked.length){ + console.error((release?'MILESTONE A RELEASE':'BASELINE')+ + ' SOURCE GATE BLOCKED: '+blocked.length+' failed checks.'); + process.exitCode=1; + } else if(release) { + console.log('MILESTONE A SOURCE CONVERGENCE ONLY: run exact-SHA JUCE/CTest, '+ + 'generated /preview/ BinaryData verifier, Windows screenshot parity and physical FAT.'); + } else { + console.log('Approved GUI/native M2 source baseline PASS. G0 may still reject '+ + 'all ChannelId actions. Use --release for strict A convergence preflight.'); + } } +if(process.argv[1] && resolve(process.argv[1])===fileURLToPath(import.meta.url)) + await cli(); diff --git a/tests/milestone_a_native_contract_test.mjs b/tests/milestone_a_native_contract_test.mjs new file mode 100644 index 000000000..259eb911b --- /dev/null +++ b/tests/milestone_a_native_contract_test.mjs @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// Milestone A: STATIC negative source-integration regression tests. +// These cannot replace real JUCE PCM/Windows screenshot/physical hardware FAT. +import test from 'node:test'; +import assert from 'node:assert/strict'; +import {collectSources,inspectMilestoneA} from '../scripts/check_console_puzzle.mjs'; + +const sources=collectSources(); +const inspect=s=>inspectMilestoneA(s); +const status=(result,id)=>[...result.baseline,...result.integration].find(x=>x.id===id); + +test('the current main-approved Windows source has no competing native mixer',()=>{ + const result=inspect(sources); + const failed=result.baseline.filter(x=>!x.pass); + assert.deepEqual(failed.map(x=>x.id),[],JSON.stringify(failed,null,2)); + assert.equal(status(result,'single-approved-pages-source').pass,true); + assert.equal(status(result,'no-retired-console-renderer').pass,true); + assert.equal(status(result,'native-four-event-socket').pass,true); + assert.equal(status(result,'gui-four-event-consumer').pass,true); +}); + +test('obsolete renderer regression immediately fails the non-release source preflight',()=>{ + const a={...sources,cmake:sources.cmake+ + '\njuce_add_binary_data(ARMixAssets SOURCES web/console-native.html)\n'}; + assert.equal(status(inspect(a),'no-retired-console-renderer').pass,false); + const b={...sources,entry:sources.entry+ + '\ndata = BinaryData::consolenative_html;\n'}; + assert.equal(status(inspect(b),'no-retired-console-renderer').pass,false); + const c={...sources,cmake:sources.cmake.replaceAll( + 'build_approved_native_gui.py','nonapproved_gui.py')}; + assert.equal(status(inspect(c),'single-approved-pages-source').pass,false); +}); + +test('breaking native event protocol or accepted-readback reconciliation blocks integration',()=>{ + const brokenEntry={...sources,entry:sources.entry.replaceAll('arMixConsoleAck','BAD_ACK')}; + assert.equal(status(inspect(brokenEntry),'native-four-event-socket').pass,false); + const brokenGui={...sources,gui:sources.gui.replaceAll('arMixConsoleSnapshot','BAD_SNAPSHOT')}; + assert.equal(status(inspect(brokenGui),'gui-four-event-consumer').pass,false); + const brokenProtocol={...sources,protocol:sources.protocol.replaceAll('readbackProvesIntent','ACK_ONLY_IS_SUCCESS')}; + assert.equal(status(inspect(brokenProtocol),'gui-four-event-consumer').pass,false); +}); + +test('engine-only graph headers or a fake native producer cannot pass milestone A',()=>{ + const fake={...sources, + nativeV8:'PuzzleV8Wire nativeBus acceptedRouting', + projection:'mainChannelId processingFormat', + entry:sources.entry+'#include "ConsoleLiveBridgeV6.h"\n', + engine:sources.engine+' nativeChannelIdPcmActive ', + }; + assert.equal(status(inspect(fake),'real-v8-producer-installed').pass,true, + 'a static adapter reference alone can match SOURCE, but is NOT audio proof'); + assert.equal(status(inspect(fake),'intent-dispatch-not-g0-rejection').pass,false, + 'G0 REJECTED dispatch must still prohibit release'); + assert.equal(inspect(fake).integration.every(x=>x.pass),false); +}); + +test('accepted native callback still requires a proper event dispatcher and physical FAT',()=>{ + const g0=inspect(sources); + if(sources.entry.includes('native_console_m2::reject (args, accepted)')) { + assert.equal(status(g0,'intent-dispatch-not-g0-rejection').pass,false); + } + // A pure source check is never proof of hardware. + assert.equal(typeof g0.g0Truthful,'boolean'); + assert.ok(g0.integration.every(x=>typeof x.pass==='boolean'&&x.release)); + assert.ok(g0.baseline.every(x=>x.release===false)); +});