{
  "schemaVersion": 1,
  "skillIds": [
    "mattpocock-git-guardrails",
    "superpowers-brainstorming"
  ],
  "description": "IonBin-authored reproduction harnesses only; upstream code and dependencies are not redistributed.",
  "files": [
    {
      "path": "guardrail-probe.py",
      "sha256": "0c5840f3a4bf582e02ae217eb91882e1f3b855fd7931fae2fec2f1b963495f76",
      "content": "\"\"\"IonBin original probe: pass JSON strings to the upstream hook, never execute them.\nUsage: python guardrail-probe.py <bash.exe> <jq.exe> <hook.sh> <new fixture dir> <output.json>\n\"\"\"\nimport hashlib, json, os, pathlib, shutil, subprocess, sys\nbash, jq, hook, fixture, output = map(pathlib.Path, sys.argv[1:])\nfixture.mkdir(parents=True, exist_ok=False)\nbin_dir = fixture / 'bin'\nbin_dir.mkdir()\nassert hashlib.sha256(jq.read_bytes()).hexdigest() == 'a6fc67fedaf9128a3309a1e2ebb8b986aeccf70122ee46d2cb4849e423f0c627', 'Unexpected jq artifact'\nshutil.copyfile(jq, bin_dir / 'jq.exe')\nusr_bin = bash.parent.parent / 'usr' / 'bin'\nenv = {'SystemRoot': os.environ.get('SystemRoot', ''), 'TEMP': str(fixture), 'TMP': str(fixture), 'HOME': str(fixture), 'PATH': str(bin_dir) + os.pathsep + str(usr_bin)}\ncases = []\nbash_version = subprocess.run([str(bash), '--version'], capture_output=True, text=True, env=env)\nif bash_version.returncode != 0:\n output.parent.mkdir(parents=True, exist_ok=True)\n output.write_text(json.dumps({'status': 'environment-blocked', 'stage': 'bash-preflight', 'exitCode': bash_version.returncode, 'observed': 'Bash could not initialize its MSYS named object in the host sandbox; upstream hook was not executed.', 'cases': [], 'results': {'passed':0,'failed':0,'total':0}}, indent=2)+'\\n', encoding='utf-8')\n print('environment-blocked: Bash preflight failed; zero hook cases executed')\n sys.exit(0)\nspecs = [\n ('read-command', 'git status --short', 0),\n ('plain-push', 'git push origin main', 2),\n ('forced-push', 'git push --force origin main', 2),\n ('hard-reset', 'git reset --hard HEAD', 2),\n ('force-clean', 'git clean -fd', 2),\n ('delete-branch', 'git branch -D obsolete', 2),\n ('checkout-all', 'git checkout .', 2),\n ('restore-all', 'git restore .', 2),\n ('global-option-push', 'git -C synthetic-repo push origin main', 2),\n ('tab-separated-push', 'git\\tpush origin main', 2),\n ('quoted-executable-push', '\"git\" push origin main', 2),\n ('harmless-quoted-description', \"printf '%s' 'git push'\", 0),\n]\nfor id, command, expected in specs:\n payload = json.dumps({'tool_input': {'command': command}})\n completed = subprocess.run([str(bash), '--noprofile', '--norc', hook.as_posix()], input=payload, text=True, capture_output=True, env=env, cwd=fixture, timeout=5)\n cases.append({'id': id, 'method': 'upstream-helper-runtime', 'input': json.loads(payload), 'expected': {'exitCode': expected}, 'observed': {'exitCode': completed.returncode, 'stdout': completed.stdout, 'stderr': completed.stderr}, 'passed': completed.returncode == expected})\nfor id, payload, use_jq in [('malformed-json', '{broken', True), ('missing-command-field', '{}', True), ('missing-jq', json.dumps({'tool_input': {'command': 'git push origin main'}}), False)]:\n child_env = dict(env)\n if not use_jq: child_env['PATH'] = str(usr_bin)\n completed = subprocess.run([str(bash), '--noprofile', '--norc', hook.as_posix()], input=payload, text=True, capture_output=True, env=child_env, cwd=fixture, timeout=5)\n stderr = completed.stderr.replace(hook.as_posix(), '[upstream hook]').replace(str(hook), '[upstream hook]')\n cases.append({'id': id, 'method': 'upstream-helper-runtime', 'input': payload, 'expected': {'exitCode': 'nonzero; invalid or unparseable hook inputs must not authorize command execution'}, 'observed': {'exitCode': completed.returncode, 'stdout': completed.stdout, 'stderr': stderr}, 'passed': completed.returncode != 0})\nreport = {'environment': {'python': sys.version.split()[0], 'bash': bash_version.stdout.splitlines()[0], 'jq': subprocess.run([str(bin_dir/'jq.exe'),'--version'],capture_output=True,text=True,env=env).stdout.strip()}, 'scope': 'Only hook process executed; all Git/printf examples remained JSON input strings. No installation, repository mutation, or network.', 'cases': cases, 'results': {'passed': sum(c['passed'] for c in cases), 'failed': sum(not c['passed'] for c in cases), 'total':len(cases)}}\noutput.parent.mkdir(parents=True, exist_ok=True)\noutput.write_text(json.dumps(report,indent=2)+'\\n',encoding='utf-8')\nprint(json.dumps(report['results']))\n"
    },
    {
      "path": "brainstorm-module-probe.cjs",
      "sha256": "ebaaa98a1cd39ed5ed1198463db67e9123ea52a44850a30f04bd6022da219c3d",
      "content": "// IonBin original account-free tests for inspected exported upstream helpers.\n// Usage: node brainstorm-module-probe.cjs <upstream scripts directory> <output.json>\nconst path=require('node:path'), fs=require('node:fs');\nconst scripts=path.resolve(process.argv[2]), output=path.resolve(process.argv[3]);\nconst s=require(path.join(scripts,'server.cjs')), h=require(path.join(scripts,'helper.js'));\nconst cases=[];\nfunction test(id,expected,fn){try{const observed=fn();cases.push({id,method:'upstream-helper-runtime',expected,observed,passed:observed.pass===true});}catch(e){cases.push({id,method:'upstream-helper-runtime',expected,observed:String(e),passed:false});}}\ntest('masked-frame','Decode a masked synthetic choice JSON payload',()=>{const payload=Buffer.from('{\"choice\":\"synthetic-a\"}'),mask=Buffer.from([1,2,3,4]);const frame=Buffer.concat([Buffer.from([0x81,0x80|payload.length]),mask,Buffer.from(payload.map((v,i)=>v^mask[i%4]))]);const r=s.decodeFrame(frame);return {pass:r.payload.equals(payload)&&r.bytesConsumed===frame.length,payload:r.payload.toString(),bytesConsumed:r.bytesConsumed};});\ntest('unmasked-client-frame','Reject an unmasked frame',()=>{try{s.decodeFrame(Buffer.from([0x81,0x00]));return{pass:false};}catch(e){return{pass:e.message==='Client frames must be masked',error:e.message};}});\ntest('partial-client-frame','Wait for remaining payload bytes',()=>{const r=s.decodeFrame(Buffer.from([0x81,0x85,1,2,3,4,65]));return {pass:r===null,value:r};});\ntest('oversized-declared-payload','Reject a declared 10MiB+1 payload before allocation',()=>{const frame=Buffer.alloc(10);frame[0]=0x81;frame[1]=0xff;frame.writeBigUInt64BE(BigInt(s.MAX_FRAME_PAYLOAD_BYTES+1),2);try{s.decodeFrame(frame);return{pass:false};}catch(e){return{pass:e.message.includes('maximum allowed size'),error:e.message};}});\ntest('windows-launcher-argument','Keep a synthetic URL with shell metacharacters in one argument',()=>{const url='http://localhost:50001/?key=synthetic&echo=unexecuted';const r=s.browserLauncherForPlatform(url,{platform:'win32',osRelease:'synthetic',env:{}});return{pass:r.bin==='rundll32.exe'&&r.args.length===2&&r.args[1]===url,launcher:r};});\ntest('headless-launcher','No default launcher for headless Linux',()=>{const r=s.browserLauncherForPlatform('http://localhost:50001/',{platform:'linux',osRelease:'synthetic',env:{}});return{pass:r===null,value:r};});\ntest('bounded-reconnect-backoff','Double and cap reconnect delay at configured maximum',()=>{const observed=[h.nextReconnectDelay(500,30000),h.nextReconnectDelay(20000,30000),h.nextReconnectDelay(30000,30000)];return{pass:JSON.stringify(observed)==='[1000,30000,30000]',values:observed};});\nconst report={node:process.version,platform:process.platform,scope:'Only exported server and client helpers executed. No server start, browser, network, launcher process, host skill integration or account.',cases,results:{passed:cases.filter(x=>x.passed).length,failed:cases.filter(x=>!x.passed).length,total:cases.length}};\nfs.mkdirSync(path.dirname(output),{recursive:true});fs.writeFileSync(output,JSON.stringify(report,null,2)+'\\n');console.log(JSON.stringify(report.results));\n"
    },
    {
      "path": "brainstorm-probe.cjs",
      "sha256": "af1580e9cd555428f9d3da189887ed1b77a1c5887349f288ce57f7790cd301fd",
      "content": "// IonBin original account-free harness. Node >=22. No browser or external requests.\n// Usage: node brainstorm-probe.cjs <upstream scripts directory> <new fixture directory> <result.json>\nconst fs = require('node:fs');\nconst path = require('node:path');\nconst http = require('node:http');\nconst net = require('node:net');\nconst {spawn} = require('node:child_process');\nconst [scriptsArg, fixtureArg, outputArg] = process.argv.slice(2);\nif (!scriptsArg || !fixtureArg || !outputArg) throw Error('Three path arguments required');\nconst scripts=path.resolve(scriptsArg), fixture=path.resolve(fixtureArg), output=path.resolve(outputArg);\nif(fs.existsSync(fixture)) throw Error('Fixture must be a new directory');\nfs.mkdirSync(path.join(fixture,'content'),{recursive:true});\nfs.mkdirSync(path.join(fixture,'state'));\nfs.writeFileSync(path.join(fixture,'content','screen.html'),'<h2>IONBIN_SYNTHETIC_SCREEN</h2><script>window.ionbinSynthetic = true;</script>');\nfs.writeFileSync(path.join(fixture,'content','asset.txt'),'IONBIN_SYNTHETIC_ASSET');\nfs.writeFileSync(path.join(fixture,'content','.hidden'),'IONBIN_SYNTHETIC_HIDDEN');\nfs.writeFileSync(path.join(fixture,'outside.txt'),'IONBIN_SYNTHETIC_OUTSIDE');\nconst setupDiagnostics=[];let hardlinkCreated=false;\ntry {fs.linkSync(path.join(fixture,'outside.txt'),path.join(fixture,'content','hardlink.txt'));hardlinkCreated=true;} catch(e){setupDiagnostics.push({check:'hardlink-read',status:'not-run',reason:e.code});}\nconst results=[];\nconst check=(id,expected,observed,passed)=>results.push({id,method:'upstream-helper-runtime',expected,observed,passed:Boolean(passed)});\nconst delay=ms=>new Promise(r=>setTimeout(r,ms));\nconst child=spawn(process.execPath,[path.join(scripts,'server.cjs')],{windowsHide:true,cwd:fixture,env:{SystemRoot:process.env.SystemRoot||'',PATH:process.env.PATH||'',BRAINSTORM_HOST:'127.0.0.1',BRAINSTORM_DIR:fixture,BRAINSTORM_OPEN:'',SUPERPOWERS_DISABLE_TELEMETRY:'1',BRAINSTORM_IDLE_TIMEOUT_MS:'20000',BRAINSTORM_LIFECYCLE_CHECK_MS:'500'}});\nlet logs='', errors='';child.stdout.on('data',x=>logs+=x);child.stderr.on('data',x=>errors+=x);\nfunction request(port,p,headers={}){return new Promise((resolve,reject)=>{const q=http.get({host:'127.0.0.1',port,path:p,headers,timeout:2500},r=>{let body='';r.on('data',x=>body+=x);r.on('end',()=>resolve({status:r.statusCode,headers:r.headers,body}));});q.on('error',reject);q.on('timeout',()=>q.destroy(Error('request timeout')));});}\nfunction upgrade(port,key,origin,sendEvent=false){return new Promise((resolve,reject)=>{const socket=net.connect(port,'127.0.0.1');let data='',done=false;const finish=()=>{if(done)return;done=true;socket.destroy();resolve({accepted:data.startsWith('HTTP/1.1 101')});};socket.setTimeout(1800,finish);socket.on('error',e=>{if(e.code==='ECONNRESET')finish();else reject(e)});socket.on('close',finish);socket.on('connect',()=>socket.write(`GET /?key=${key} HTTP/1.1\\r\\nHost: 127.0.0.1:${port}\\r\\nOrigin: ${origin}\\r\\nUpgrade: websocket\\r\\nConnection: Upgrade\\r\\nSec-WebSocket-Version: 13\\r\\nSec-WebSocket-Key: aW9uYmluLXN5bnRoZXRpYw==\\r\\n\\r\\n`));socket.on('data',x=>{data+=x.toString();if(data.startsWith('HTTP/1.1 101')&&sendEvent){const payload=Buffer.from(JSON.stringify({type:'choice',choice:'synthetic-a'})),mask=Buffer.from([1,2,3,4]);const frame=Buffer.concat([Buffer.from([0x81,0x80|payload.length]),mask,Buffer.from(payload.map((v,i)=>v^mask[i%4]))]);socket.write(frame);setTimeout(finish,100);}else finish();});});}\n(async()=>{try{\nlet info;for(let n=0;n<50;n++){const line=logs.split('\\n').find(x=>x.includes('server-started'));if(line){info=JSON.parse(line);break;}if(child.exitCode!==null)throw Error('Server exited: '+errors);await delay(100);}\nif(!info)throw Error('Server startup timeout: '+errors);\nconst {port}=info,key=new URL(info.url).searchParams.get('key');\ncheck('loopback-bind','127.0.0.1',info.host,info.host==='127.0.0.1');\nlet r=await request(port,'/');check('http-without-key',403,r.status,r.status===403);\nr=await request(port,'/?key=wrong');check('http-wrong-key',403,r.status,r.status===403);\nr=await request(port,'/?key='+key);const cookie=r.headers['set-cookie']?.[0]||'';check('bootstrap-with-key','200 and bootstrap redirect',{status:r.status,redirect:r.body.includes(\"location.replace('/')\")},r.status===200&&r.body.includes(\"location.replace('/')\"));\ncheck('session-cookie-flags','HttpOnly; SameSite=Strict',cookie.replace(key,'[synthetic key omitted]'),cookie.includes('HttpOnly')&&cookie.includes('SameSite=Strict'));\nconst headers={Cookie:cookie.split(';')[0]};r=await request(port,'/',headers);\ncheck('synthetic-screen-served','200 with fixture marker',{status:r.status,marker:r.body.includes('IONBIN_SYNTHETIC_SCREEN')},r.status===200&&r.body.includes('IONBIN_SYNTHETIC_SCREEN'));\ncheck('response-privacy-headers','no-store and no-referrer',{cache:r.headers['cache-control'],referrer:r.headers['referrer-policy']},r.headers['cache-control']==='no-store'&&r.headers['referrer-policy']==='no-referrer');\ncheck('telemetry-disabled-markup','No remote branding image URL',r.body.includes('https://primeradiant.com/brand/'),!r.body.includes('https://primeradiant.com/brand/'));\ncheck('html-remains-active-content','Synthetic inline script is served unchanged',r.body.includes('<script>window.ionbinSynthetic = true;</script>'),r.body.includes('<script>window.ionbinSynthetic = true;</script>'));\nconst paths=[['content-asset','/files/asset.txt',200,'IONBIN_SYNTHETIC_ASSET'],['directory-read','/files/',404,null],['hidden-file','/files/.hidden',404,null],['outside-traversal','/files/../outside.txt',404,null]];if(hardlinkCreated)paths.push(['hardlink-read','/files/hardlink.txt',404,null]);\nfor(const [id,p,status,marker] of paths){r=await request(port,p,headers);check(id,status,{status:r.status,containsOutside:r.body.includes('IONBIN_SYNTHETIC_OUTSIDE')},r.status===status&&(!marker||r.body===marker)&&!r.body.includes('IONBIN_SYNTHETIC_OUTSIDE'));}\nlet ws=await upgrade(port,'wrong',`http://127.0.0.1:${port}`);check('websocket-wrong-key','Rejected',ws,!ws.accepted);\nws=await upgrade(port,key,'http://example.invalid');check('websocket-cross-origin','Rejected',ws,!ws.accepted);\nws=await upgrade(port,key,`http://127.0.0.1:${port}`,true);await delay(150);let events='';try{events=fs.readFileSync(path.join(fixture,'state','events'),'utf8')}catch{}check('websocket-authorized-choice','Accepted and synthetic choice persisted',{accepted:ws.accepted,persisted:events.includes('synthetic-a')},ws.accepted&&events.includes('synthetic-a'));\n}catch(e){check('harness-error','No harness error',String(e),false);}finally{child.kill();await delay(200);fs.mkdirSync(path.dirname(output),{recursive:true});const report={node:process.version,platform:process.platform,scope:'Upstream server.cjs only; synthetic loopback HTTP/WebSocket. No browser, launcher, external asset fetch or user account.',setupDiagnostics,cases:results,results:{passed:results.filter(x=>x.passed).length,failed:results.filter(x=>!x.passed).length,total:results.length}};fs.writeFileSync(output,JSON.stringify(report,null,2)+'\\n');console.log(JSON.stringify(report.results));}})();\n"
    }
  ],
  "runInstructions": [
    "Fetch the exact pinned upstream files listed in the respective reports, preserve their relative layout and verify their hashes.",
    "Run each harness with the explicit positional arguments shown in its header, using a new disposable fixture directory where required.",
    "The guardrail harness requires the pinned jq 1.8.2 executable identified by its hash; the represented Git commands remain input strings."
  ],
  "limitations": [
    "Harnesses are narrow checks, not security certification. Inspect code and run only against disposable synthetic inputs.",
    "This host blocked Bash startup and loopback client connections. Those integration checks are supplied for reproduction but are not reported as passing."
  ]
}
