make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();$n=json_decode(file_get_contents($s['root'].'/native-fixture.json'),true);config(['database.connections.history_demo'=>$s['nativeConnection']]);$db=DB::connection('history_demo');$checks=[];$ok=function($v,$name)use(&$checks){if(!$v)throw new RuntimeException($name);$checks[]=$name;};$fingerprint=fn()=>hash('sha256',json_encode([$db->table('requisitions')->orderBy('id')->get(),$db->table('audit_logs')->orderBy('id')->get(),DB::table('permission_grants')->orderBy('id')->get()]));$before=$fingerprint();$ok($db->table('requisitions')->where('tenant_id',$n['tenant'])->count()===0,'fresh demonstration has no main request or history-volume fixtures');$client=new GuzzleHttp\Client(['base_uri'=>'http://127.0.0.1:8080','http_errors'=>false,'timeout'=>25]);$jar=new GuzzleHttp\Cookie\CookieJar;$r=$client->get('/qa/enter/requester',['cookies'=>$jar]);$v=json_decode((string)$r->getBody(),true);$options=['cookies'=>$jar,'headers'=>['Accept'=>'application/json','X-SGF-Context'=>$v['context']]];$r=$client->get('/purchasing/requests',$options);$ok($r->getStatusCode()===200,'request workspace remains mounted for original requester right');$r=$client->get('/api/purchasing-requests/999999/history',$options);$ok(in_array($r->getStatusCode(),[403,404],true),'unknown history source grants no access and creates no record');foreach(['request-workspace.mjs','request-history.mjs']as$file){$r=$client->get('/'.$file);$ok($r->getStatusCode()===200&&hash('sha256',(string)$r->getBody())===hash_file('sha256',$s['app'].'/public/'.$file),'served history module matches '.$file);}$ok($fingerprint()===$before,'demonstration probes preserve requests native audit and permission grants');file_put_contents($out,json_encode(['passed'=>true,'checks'=>$checks,'before'=>$before,'after'=>$fingerprint(),'visual_review'=>false],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo count($checks)." request history demo checks passed.\n";