make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap(); \App\Shared\Testing\TestingDatabaseGuard::assertSafe(); $f=json_decode(file_get_contents('C:/laragon/data/sgf-tempo/secrets/browser-fixture.json'),true,32,JSON_THROW_ON_ERROR); $c=app(\App\Modules\Services\CatalogueAccounting::class); app(\App\Shared\Context\CompanyContext::class)->selectFor($f['manager_id'],$f['tenant'],$f['company'],$f['unit']); $proposal=$c->propose($f['manager_id'],['kind'=>'category','data'=>['name'=>'Categoria de concorrência sintética','account_id'=>$f['accounting_account'],'conditions'=>'Somente ensaio de decisões concorrentes.'],'valid_from'=>'2026-01-01','reason'=>'Ensaiar concorrência sem operações reais.'],(string)Str::uuid())['id'];$c->submit($proposal,$f['manager_id'],(string)Str::uuid()); $base=['actor'=>$f['reader_id'],'tenant'=>$f['tenant'],'company'=>$f['company'],'unit'=>$f['unit'],'proposal'=>$proposal]; $a=new Process([PHP_BINARY,'scripts/accounting-concurrency-worker.php','--env=testing'],base_path(),null,json_encode($base+['pause'=>true,'decision'=>'approved','key'=>(string)Str::uuid()])); $b=new Process([PHP_BINARY,'scripts/accounting-concurrency-worker.php','--env=testing'],base_path(),null,json_encode($base+['decision'=>'refused','key'=>(string)Str::uuid()])); $a->start();if(!$a->waitUntil(fn($type,$buffer)=>str_contains($buffer,'LOCK_HELD')))throw new RuntimeException('Concurrent lock not observed.');$b->start();$a->wait();$b->wait(); $statuses=[];foreach([$a,$b] as $p){if(!$p->isSuccessful())throw new RuntimeException('Decision worker failed.');$lines=array_values(array_filter(explode("\n",trim($p->getOutput())),fn($s)=>str_starts_with($s,'{')));$statuses[]=json_decode(end($lines),true,32,JSON_THROW_ON_ERROR)['status'];} if($statuses!==[200,409]||DB::table('ca_decisions')->where('proposal_id',$proposal)->count()!==1)throw new RuntimeException('Contradictory decision accepted.'); file_put_contents(base_path('docs/proofs/accounting-concurrency.json'),json_encode(['database'=>'sgf_tempo_test','parallel_processes'=>true,'lock_overlap_observed'=>true,'statuses'=>$statuses,'decisions'=>1],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo "Concurrent approval/refusal verified: one decision accepted, conflicting decision refused (409).\n";