e0dd400371
- scripts/freeze-versionset.ps1: Parameterized tool to freeze model/dataset VersionSet * Inserts FROZEN records into governance.model_version_registry + evaluation.dataset_manifest * NO default values — all 5 parameters REQUIRED (-ModelId, -DatasetId, -ApprovedBy, -ConfigVersion, -CodeSha) * Fails immediately if any parameter missing (enforces discipline) * Pre-flight: Verifies migration 0032 deployed before proceeding * Rationale: Prevents accidental partial freezes; seed data only with explicit values - scripts/generate-shadow-run-identifiers.ps1: Reusable UUID generation script * Generates cryptographic UUIDs for Phase 1: RunId, JobId, JobRunId, CorrelationId, IdempotencyKey * Outputs JSON (versionset.json) for use in STEP 3 * Rationale: Decoupled from freeze; can re-run if identifiers lost - docs/CURRENT/PHASE-1_ACTIVATION_RUNBOOK.md: Executable runbook * 3-step activation: (1) FREEZE VersionSet, (2) GENERATE identifiers, (3) ENQUEUE Job 893 * Pre-flight checklist: Migration, Host (Debug mode), SSH tunnel, Hangfire, scripts * Detailed expected outputs + troubleshooting matrix * Monitoring: Live logs, Grafana metrics, evidence artifacts * Emergency rollback procedure * ~15 min setup; 50-90 day autonomous execution AGENTS.md: Necessity (real tooling gap: no VersionSet freeze script), Maturity (runbook before execution), Right-Way (parameterized + validation vs ad-hoc SQL). Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
91 lines
3.8 KiB
PowerShell
91 lines
3.8 KiB
PowerShell
#!/usr/bin/env pwsh
|
|
<#
|
|
.SYNOPSIS
|
|
Generate Phase 1 shadow run identifiers (RunId, JobId, JobRunId, CorrelationId, Idempotency-Key).
|
|
|
|
.DESCRIPTION
|
|
Produces a JSON-formatted versionset.json file with all identifiers needed to enqueue Phase 1.
|
|
Uses CRYPTOGRAPHIC random UUIDs and correlation for full traceability.
|
|
|
|
.PARAMETER OutputPath
|
|
Path to save versionset.json (default: ./versionset.json in current directory)
|
|
|
|
.EXAMPLE
|
|
.\generate-shadow-run-identifiers.ps1 -OutputPath ./phase1-versionset.json
|
|
|
|
.OUTPUTS
|
|
JSON file with structure:
|
|
{
|
|
"phase1_run": {
|
|
"runId": "UUID",
|
|
"jobId": "UUID",
|
|
"jobRunId": "UUID",
|
|
"correlationId": "UUID",
|
|
"idempotencyKey": "UUID",
|
|
"generatedAt": "ISO8601 timestamp",
|
|
"usage": "Use these IDs to enqueue Job 893 in Hangfire..."
|
|
}
|
|
}
|
|
#>
|
|
|
|
[CmdletBinding()]
|
|
param(
|
|
[string]$OutputPath = "./versionset.json"
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Cyan
|
|
Write-Host "Phase 1: Generate Shadow Run Identifiers" -ForegroundColor Cyan
|
|
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Cyan
|
|
|
|
Write-Host "`n[1/3] Generating cryptographic UUIDs..."
|
|
|
|
$runId = [System.Guid]::NewGuid()
|
|
$jobId = [System.Guid]::NewGuid()
|
|
$jobRunId = [System.Guid]::NewGuid()
|
|
$correlationId = [System.Guid]::NewGuid()
|
|
$idempotencyKey = [System.Guid]::NewGuid()
|
|
|
|
Write-Host " ✅ RunId: $runId"
|
|
Write-Host " ✅ JobId: $jobId"
|
|
Write-Host " ✅ JobRunId: $jobRunId"
|
|
Write-Host " ✅ CorrelationId: $correlationId"
|
|
Write-Host " ✅ IdempotencyKey: $idempotencyKey"
|
|
|
|
Write-Host "`n[2/3] Creating JSON payload..."
|
|
|
|
$payload = @{
|
|
phase1_run = @{
|
|
runId = $runId.ToString()
|
|
jobId = $jobId.ToString()
|
|
jobRunId = $jobRunId.ToString()
|
|
correlationId = $correlationId.ToString()
|
|
idempotencyKey = $idempotencyKey.ToString()
|
|
generatedAt = [System.DateTime]::UtcNow.ToString("o")
|
|
windowStart = "2024-01-02"
|
|
windowEnd = "2024-09-10"
|
|
usage = "Use these IDs to enqueue Job 893 (Phase 1 shadow run) in Hangfire. Command: `n Invoke-WebRequest -Uri 'http://127.0.0.1:5002/api/shadow-runs' -Method POST -Headers @{ 'X-KArtSell-User'='admin'; 'X-KArtSell-Role'='Admin'; 'Content-Type'='application/json' } -Body (ConvertTo-Json @{ modelId='<modelId>'; datasetId='<datasetId>'; windowStart='2024-01-02'; windowEnd='2024-09-10'; phaseFilter='All' })"
|
|
}
|
|
}
|
|
|
|
Write-Host " ✅ JSON payload generated"
|
|
|
|
Write-Host "`n[3/3] Writing to file: $OutputPath"
|
|
|
|
$json = $payload | ConvertTo-Json -Depth 10
|
|
$json | Out-File -FilePath $OutputPath -Encoding UTF8
|
|
|
|
Write-Host " ✅ File saved: $(Resolve-Path $OutputPath)"
|
|
|
|
Write-Host "`n✅ IDENTIFIERS GENERATED`n"
|
|
Write-Host $json -ForegroundColor Green
|
|
|
|
Write-Host "`nNext Steps:`n"
|
|
Write-Host " 1. Copy the identifiers from above or read from $OutputPath"
|
|
Write-Host " 2. Call POST /api/shadow-runs with modelId/datasetId from frozen VersionSet"
|
|
Write-Host " 3. Hangfire will enqueue Job 893 with these correlation IDs"
|
|
Write-Host " 4. Monitor logs: grep 'CorrelationId: $correlationId' app.log"
|
|
|
|
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Cyan
|