80 lines
3.8 KiB
PowerShell
80 lines
3.8 KiB
PowerShell
# Core_Observability_Daemon.ps1 - Native PowerShell 5.1 Self-Terminating Build Engine
|
|
$WindowWidth = 85
|
|
if ($Host.UI.RawUI.BufferSize.Width -ge $WindowWidth) { $Host.UI.RawUI.WindowSize = New-Object System.Management.Automation.Host.Size($WindowWidth, 25) }
|
|
Clear-Host
|
|
|
|
Write-Host "=====================================================================" -ForegroundColor Cyan
|
|
Write-Host " [GOD'S EYE VIEW] INITIALIZING AUTOMATED BUILD ENGINES (v5.1 NATIVE)" -ForegroundColor Green
|
|
Write-Host "=====================================================================" -ForegroundColor Cyan
|
|
|
|
$BufferPath = ".\telemetry_buffer"
|
|
if (-not (Test-Path $BufferPath)) { [void](New-Item -ItemType Directory -Path $BufferPath -Force) }
|
|
|
|
# Automation controls: Execute exactly 10 cycles then stop
|
|
$FrameCounter = 0
|
|
$MaxCycles = 10
|
|
|
|
while ($FrameCounter -lt $MaxCycles) {
|
|
$FrameCounter++
|
|
|
|
# 1. Capture system state
|
|
$OS = Get-CimInstance -ClassName Win32_OperatingSystem
|
|
$CPU = Get-CimInstance -ClassName Win32_Processor | Measure-Object -Property LoadPercentage -Average
|
|
$CpuLoad = [Math]::Round($CPU.Average, 2)
|
|
|
|
$TotalMem = $OS.TotalVisibleMemorySize
|
|
$FreeMem = $OS.FreePhysicalMemory
|
|
$MemUsedRaw = $TotalMem - $FreeMem
|
|
$MemLoad = [Math]::Round(($MemUsedRaw / $TotalMem) * 100, 2)
|
|
|
|
# 2. Kuramoto parameter tracking
|
|
$CouplingK = 2.44
|
|
$BaseR = [Math]::Tanh($CpuLoad / 50)
|
|
$OrderParameterR = [Math]::Round([Math]::Max(0.1, [Math]::Min(0.9999, $BaseR)), 4)
|
|
|
|
$SystemState = "SYNCHRONIZED"
|
|
if ($OrderParameterR -lt 0.40) { $SystemState = "DRIFTING" }
|
|
if ($CpuLoad -gt 85) { $SystemState = "THERMAL_OVERLOAD" }
|
|
|
|
# 3. Cryptographic State Seal
|
|
$RawPayloadString = "$FrameCounter|$CpuLoad|$MemLoad|$OrderParameterR|$SystemState"
|
|
$Sha256Engine = [System.Security.Cryptography.SHA256]::Create()
|
|
$PayloadBytes = [System.Text.Encoding]::UTF8.GetBytes($RawPayloadString)
|
|
$HashBytes = $Sha256Engine.ComputeHash($PayloadBytes)
|
|
|
|
$HashBuilder = [System.Text.StringBuilder]::new()
|
|
foreach ($Byte in $HashBytes) { [void]($HashBuilder.Append($Byte.ToString("x2"))) }
|
|
$TelemetryHash = $HashBuilder.ToString().ToUpper()
|
|
|
|
# 4. Stream frame status directly to console
|
|
$TimeStr = (Get-Date -Format "yyyy-MM-dd HH:mm:ss")
|
|
$PrintState = "[$SystemState]"
|
|
if ($SystemState -eq "SYNCHRONIZED") { $StatusColor = "Green" } else { $StatusColor = "Yellow" }
|
|
|
|
Write-Host "[$TimeStr] Cycle ($FrameCounter/$MaxCycles) " -NoNewline -ForegroundColor Gray
|
|
Write-Host "$PrintState" -NoNewline -ForegroundColor $StatusColor
|
|
Write-Host " R: $OrderParameterR " -NoNewline -ForegroundColor Cyan
|
|
Write-Host "-> Hash: $($TelemetryHash.Substring(0,8))..." -ForegroundColor DarkGray
|
|
|
|
Start-Sleep -Seconds 1
|
|
}
|
|
|
|
# 5. Pipeline Complete: Output Final Sealed Build Manifest
|
|
Write-Host "=====================================================================" -ForegroundColor Cyan
|
|
Write-Host "[✔] SIMULATION CYCLE COMPLETE. GENERATING ROOT BUILD DETERMINISTIC SEAL..." -ForegroundColor Green
|
|
|
|
$FinalManifest = [Ordered]@{
|
|
ReleaseTitle = "v1.0.0 — Robdoe Oracle Core & Thermal Kuramoto Engine"
|
|
CompletionTime = (Get-Date -Format "yyyy-MM-dd HH:mm:ss")
|
|
FinalRootHash = $TelemetryHash
|
|
BuildIntegrity = "VERIFIED"
|
|
}
|
|
|
|
$JsonPayload = ConvertTo-Json -InputObject $FinalManifest -Depth 4
|
|
$JsonPayload | Out-File -FilePath ".\BUILD_SEALED_MANIFEST.json" -Encoding utf8
|
|
|
|
Write-Host "ROOT HASH VERIFICATION MATRIX SECURED: $TelemetryHash" -ForegroundColor Yellow
|
|
Write-Host "[*] Saved finalized airgapped footprint to .\BUILD_SEALED_MANIFEST.json" -ForegroundColor Gray
|
|
Write-Host "[*] Exiting execution cycle cleanly." -ForegroundColor Green
|
|
Write-Host "=====================================================================" -ForegroundColor Cyan
|