?# gov_pipeline_run_safe_v1.0.ps1 # Orchestration: preflight doctor -> interactive write -> postflight doctor (+ optional acceptance). # ASCII-only, PS 5.1-safe, no here-strings. param( [string]$Root = "\\\\DS-918\\chatgpt\\ChatGPT-Gouvernance-Projets\\_registry", [switch]$Utf8Console, [switch]$RunAcceptance ) if($Utf8Console){ try{ [Console]::OutputEncoding = [Text.Encoding]::UTF8 }catch{} } function Exists([string]$p){ return (-not [string]::IsNullOrWhiteSpace($p)) -and (Test-Path -LiteralPath $p) } function Fail([int]$code,[string]$msg){ Write-Host $msg; exit $code } $scriptsDir = Join-Path $Root "scripts" $doctor = Join-Path $scriptsDir "gov_pipeline_doctor_ultra_min_v1.2.ps1" $interactive= Join-Path $scriptsDir "gov_pipeline_interactive_write_v1.0.ps1" $acceptance = Join-Path $scriptsDir "kb_acceptance_tests_v1.0.1.ps1" Write-Host "== GOV PIPELINE :: SAFE-RUN v1.0 ==" Write-Host ("Root : {0}" -f $Root) if(-not (Exists $doctor)) { Fail 3 ("[FATAL] missing: " + $doctor) } if(-not (Exists $interactive)){ Fail 3 ("[FATAL] missing: " + $interactive) } if($RunAcceptance -and -not (Exists $acceptance)){ Write-Host ("[WARN] acceptance not found: {0}" -f $acceptance) } Write-Host "[1/3] Preflight doctor..." $p = Start-Process powershell -NoNewWindow -PassThru -Wait -ArgumentList @("-NoProfile","-ExecutionPolicy","Bypass","-File",$doctor,"-Root",$Root,"-Utf8Console") if($p.ExitCode -ne 0){ Fail 2 "[STOP] Preflight failed. Fix before proceeding." } Write-Host "[2/3] Interactive pipeline (preview + consent -> write)..." $p = Start-Process powershell -NoNewWindow -PassThru -Wait -ArgumentList @("-NoProfile","-ExecutionPolicy","Bypass","-File",$interactive,"-Utf8Console") if($p.ExitCode -ne 0){ Fail 2 "[STOP] Interactive pipeline failed." } Write-Host "[3/3] Postflight doctor..." $p = Start-Process powershell -NoNewWindow -PassThru -Wait -ArgumentList @("-NoProfile","-ExecutionPolicy","Bypass","-File",$doctor,"-Root",$Root,"-Utf8Console") if($p.ExitCode -ne 0){ Fail 2 "[STOP] Postflight doctor failed." } if($RunAcceptance -and (Test-Path -LiteralPath $acceptance)){ Write-Host "[+A] Acceptance (robust)..." $p = Start-Process powershell -NoNewWindow -PassThru -Wait -ArgumentList @("-NoProfile","-ExecutionPolicy","Bypass","-File",$acceptance,$Root) if($p.ExitCode -ne 0){ Fail 2 "[STOP] Acceptance failed." } } Write-Host "[DONE] Safe-run completed successfully."