@trillboards/edge-sdk 0.2.197 → 0.2.203
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deploy/detector/pyproject.toml +1 -1
- package/deploy/detector/tests/test_colors_v2.py +79 -0
- package/deploy/detector/tests/test_detection_colors_wire.py +25 -0
- package/deploy/detector/tests/test_held_phone_customer_packaging.py +102 -0
- package/deploy/detector/trillboards_detector/_version.py +2 -2
- package/deploy/detector/trillboards_detector/colors.py +30 -11
- package/deploy/detector/trillboards_detector/server.py +1 -1
- package/deploy/macos/build-macos-pkg.sh +14 -2
- package/deploy/windows/build-windows.ps1 +12 -2
- package/deploy/windows/ci/test-published-install.ps1 +486 -15
- package/deploy/windows/setup-detector.ps1 +4 -1
- package/dist/DetectionColors.d.ts +11 -4
- package/dist/DetectionColors.d.ts.map +1 -1
- package/dist/DetectionColors.js +5 -2
- package/dist/DetectionColors.js.map +1 -1
- package/dist/DetectorFields.d.ts +138 -4
- package/dist/DetectorFields.d.ts.map +1 -1
- package/dist/DetectorFields.js +101 -11
- package/dist/DetectorFields.js.map +1 -1
- package/dist/EdgeAgent.js +1 -1
- package/dist/LiteRtVlmProvider.d.ts.map +1 -1
- package/dist/LiteRtVlmProvider.js +10 -1
- package/dist/LiteRtVlmProvider.js.map +1 -1
- package/dist/PhoneEmbeddingClassifier.d.ts +28 -0
- package/dist/PhoneEmbeddingClassifier.d.ts.map +1 -0
- package/dist/PhoneEmbeddingClassifier.js +40 -0
- package/dist/PhoneEmbeddingClassifier.js.map +1 -0
- package/dist/RetainedFieldContract.d.ts +9 -1
- package/dist/RetainedFieldContract.d.ts.map +1 -1
- package/dist/RetainedFieldContract.js +19 -3
- package/dist/RetainedFieldContract.js.map +1 -1
- package/dist/ScopedVlmReview.d.ts +6 -2
- package/dist/ScopedVlmReview.d.ts.map +1 -1
- package/dist/ScopedVlmReview.js +55 -5
- package/dist/ScopedVlmReview.js.map +1 -1
- package/dist/SensingProfileClient.d.ts +6 -0
- package/dist/SensingProfileClient.d.ts.map +1 -1
- package/dist/SensingProfileClient.js +7 -0
- package/dist/SensingProfileClient.js.map +1 -1
- package/dist/diagnose.d.ts +1 -1
- package/dist/diagnose.js +1 -1
- package/dist/localSensing.d.ts +5 -2
- package/dist/localSensing.d.ts.map +1 -1
- package/dist/localSensing.js +56 -8
- package/dist/localSensing.js.map +1 -1
- package/package.json +3 -3
- package/retained/ProfileAuthorityClient.cjs +1 -1
- package/retained/RetainedCaptureClient.cjs +2 -1
- package/retained/WebsiteAdmissionCaptureClient.cjs +478 -0
- package/retained/WebsiteAdmissionState.cjs +75 -0
- package/retained/__tests__/actor-perception.test.cjs +1 -1
- package/retained/__tests__/actor-window.test.cjs +1 -1
- package/retained/__tests__/archive-lifecycle.test.cjs +1 -1
- package/retained/__tests__/runtime.test.cjs +30 -2
- package/retained/__tests__/website-admission-realtime.test.cjs +503 -0
- package/retained/__tests__/website-admission.test.cjs +806 -0
- package/retained/manager.cjs +4 -1
- package/retained/pilot-profile-client.cjs +2 -1
|
@@ -142,15 +142,494 @@ function Wait-DetectorAnswer {
|
|
|
142
142
|
throw 'The installed detector did not answer after restart'
|
|
143
143
|
}
|
|
144
144
|
function Assert-ImageInference {
|
|
145
|
+
param([string]$InferenceModel = 'gemma-4-E2B-it.litertlm', [string]$ExpectedModelSha256 = '', [System.Collections.IDictionary]$Evidence = $null)
|
|
145
146
|
$image = [Convert]::ToBase64String([IO.File]::ReadAllBytes($PersonFrame))
|
|
146
|
-
$body = @{ model =
|
|
147
|
+
$body = @{ model = $InferenceModel; max_completion_tokens = 256; temperature = 0;
|
|
147
148
|
messages = @(@{ role = 'user'; content = @(@{ type = 'text'; text = 'Look at the image. Is there a person visible? Answer YES or NO.' },
|
|
148
149
|
@{ type = 'image_url'; image_url = @{ url = ('data:image/jpeg;base64,' + $image) } }) }) } | ConvertTo-Json -Depth 10
|
|
149
|
-
$
|
|
150
|
+
$request = @{ Uri = 'http://127.0.0.1:9379/v1/chat/completions'; Method = 'Post'; ContentType = 'application/json'; Body = $body; TimeoutSec = 240 }
|
|
151
|
+
if ($ExpectedModelSha256) {
|
|
152
|
+
# Same endpoint and selected delegate as the default Windows customer client.
|
|
153
|
+
$request.Uri = 'http://localhost:9379/v1/chat/completions'
|
|
154
|
+
$request.Headers = @{ 'X-Trillboards-Model-Sha256' = $ExpectedModelSha256 }
|
|
155
|
+
}
|
|
156
|
+
if ($null -ne $Evidence) {
|
|
157
|
+
$Evidence.request = [ordered]@{ uri = $request.Uri; model = $InferenceModel; modelSha256 = $ExpectedModelSha256;
|
|
158
|
+
personImageSha256 = (Get-FileHash -LiteralPath $PersonFrame -Algorithm SHA256).Hash.ToLowerInvariant();
|
|
159
|
+
maxCompletionTokens = 256; temperature = 0; timeoutSeconds = 240 }
|
|
160
|
+
}
|
|
161
|
+
$answer = Invoke-RestMethod @request
|
|
162
|
+
if ($null -ne $Evidence) { $Evidence.response = $answer }
|
|
163
|
+
if ($ExpectedModelSha256) { Assert-QualificationRuntimeProof $answer $InferenceModel $ExpectedModelSha256 }
|
|
150
164
|
if (@($answer.choices).Count -lt 1 -or [string]$answer.choices[0].message.content -notmatch '(?i)\byes\b') {
|
|
151
165
|
throw 'The installed model did not confirm the person in the committed image fixture'
|
|
152
166
|
}
|
|
153
167
|
}
|
|
168
|
+
function Get-QualificationClockSeconds { [Diagnostics.Stopwatch]::GetTimestamp() / [double][Diagnostics.Stopwatch]::Frequency }
|
|
169
|
+
function New-QualificationSetupBarrier {
|
|
170
|
+
$sid = [Security.Principal.WindowsIdentity]::GetCurrent().User.Value
|
|
171
|
+
New-Object System.Threading.Mutex($false, ('Global\TrillboardsLiteRtLmSetup-' + $sid))
|
|
172
|
+
}
|
|
173
|
+
function Get-QualificationModelConfigPath { Join-Path $env:USERPROFILE '.litert-lm\config.json' }
|
|
174
|
+
function Invoke-QualificationModelInspection {
|
|
175
|
+
# Reuse installed ownership validation, including SID, uv runtime and foreign listeners.
|
|
176
|
+
& (Join-Path $installDir 'bin\stop-local-ai.ps1') -Service Model -Inspect
|
|
177
|
+
}
|
|
178
|
+
function Get-QualificationModelSnapshot {
|
|
179
|
+
$snapshot = [ordered]@{ ready = $false; atUtc = [DateTimeOffset]::UtcNow.ToString('o'); reason = 'config-unverified' }
|
|
180
|
+
$path = Get-QualificationModelConfigPath
|
|
181
|
+
$snapshot.configPath = $path
|
|
182
|
+
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) { return $snapshot }
|
|
183
|
+
$snapshot.configSha256 = (Get-FileHash -LiteralPath $path -Algorithm SHA256).Hash.ToLowerInvariant()
|
|
184
|
+
$snapshot.configText = [IO.File]::ReadAllText($path)
|
|
185
|
+
try { $snapshot.config = $snapshot.configText | ConvertFrom-Json } catch {
|
|
186
|
+
$snapshot.reason = 'config-invalid'; $snapshot.configError = $_.Exception.Message; return $snapshot
|
|
187
|
+
}
|
|
188
|
+
if ((Get-FileHash -LiteralPath $path -Algorithm SHA256).Hash -ine $snapshot.configSha256) {
|
|
189
|
+
$snapshot.reason = 'config-changing'; return $snapshot
|
|
190
|
+
}
|
|
191
|
+
$models = $snapshot.config.PSObject.Properties['models']
|
|
192
|
+
if ($null -eq $models) { return $snapshot }
|
|
193
|
+
$model = $models.Value.PSObject.Properties['gemma-4-E2B-it.litertlm']
|
|
194
|
+
if ($null -eq $model) { return $snapshot }
|
|
195
|
+
$backend = $model.Value.PSObject.Properties['backend']
|
|
196
|
+
if ($null -eq $backend -or [string]$backend.Value -notin @('cpu','gpu','npu')) { return $snapshot }
|
|
197
|
+
$snapshot.backend = [string]$backend.Value
|
|
198
|
+
# LiteRtVlmProvider.ts:450-458,607-636: auto uses verified Windows CPU; otherwise GPU.
|
|
199
|
+
$snapshot.inferenceModel = 'gemma-4-E2B-it.litertlm,' + $(if ($snapshot.backend -eq 'cpu') { 'cpu' } else { 'gpu' })
|
|
200
|
+
$snapshot.ownership = Invoke-QualificationModelInspection
|
|
201
|
+
if (-not $snapshot.ownership.TaskPresent -or -not $snapshot.ownership.Enabled -or -not $snapshot.ownership.Running -or
|
|
202
|
+
$snapshot.ownership.Port -ne 9379 -or $snapshot.ownership.ListenerCount -lt 1) {
|
|
203
|
+
$snapshot.reason = 'owned-service-not-listening'; return $snapshot
|
|
204
|
+
}
|
|
205
|
+
$listeners = @(Get-NetTCPConnection -LocalPort 9379 -State Listen -ErrorAction Stop | Select-Object -ExpandProperty OwningProcess -Unique)
|
|
206
|
+
if ($listeners.Count -ne 1) { $snapshot.reason = 'ambiguous-producer'; return $snapshot }
|
|
207
|
+
$producer = @(Get-CimInstance -ClassName Win32_Process -Filter ('ProcessId=' + $listeners[0]) -OperationTimeoutSec 5 -ErrorAction Stop)
|
|
208
|
+
if ($producer.Count -ne 1 -or -not $producer[0].CreationDate -or -not $producer[0].ExecutablePath -or -not $producer[0].CommandLine) {
|
|
209
|
+
$snapshot.reason = 'producer-identity-unavailable'; return $snapshot
|
|
210
|
+
}
|
|
211
|
+
$snapshot.producer = [ordered]@{ processId = [int]$producer[0].ProcessId; creationDate = [string]$producer[0].CreationDate;
|
|
212
|
+
executablePath = [string]$producer[0].ExecutablePath; commandLine = [string]$producer[0].CommandLine }
|
|
213
|
+
# Recheck authority after reading the producer; never accept a newly foreign listener.
|
|
214
|
+
$null = Invoke-QualificationModelInspection
|
|
215
|
+
$snapshot.ready = $true; $snapshot.reason = 'owned-verified-configuration'
|
|
216
|
+
return $snapshot
|
|
217
|
+
}
|
|
218
|
+
function Assert-QualificationModelGeneration($Before, $After) {
|
|
219
|
+
if (-not $Before.ready -or -not $After.ready -or $Before.configSha256 -cne $After.configSha256 -or
|
|
220
|
+
$Before.backend -cne $After.backend -or $Before.inferenceModel -cne $After.inferenceModel -or
|
|
221
|
+
$Before.producer.processId -ne $After.producer.processId -or $Before.producer.creationDate -cne $After.producer.creationDate -or
|
|
222
|
+
$Before.producer.executablePath -cne $After.producer.executablePath -or $Before.producer.commandLine -cne $After.producer.commandLine) {
|
|
223
|
+
throw 'The model configuration or producer generation changed during restart qualification'
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function Get-QualificationConnectorTaskState {
|
|
228
|
+
$diagnostic = [ordered]@{ taskName='TrillboardsEdge'; taskPath='\'; cimEnabled=$null; cimEnabledType='unavailable'; rawTaskXml=$null }
|
|
229
|
+
try {
|
|
230
|
+
$task = Get-ScheduledTask -TaskName 'TrillboardsEdge' -TaskPath '\' -ErrorAction Stop
|
|
231
|
+
$value = $task.Settings.Enabled
|
|
232
|
+
$diagnostic.cimEnabled = if ($value -is [bool]) { $value } else { $null }
|
|
233
|
+
$type = if ($null -eq $value) { 'null' } else { $value.GetType().FullName }
|
|
234
|
+
$diagnostic.cimEnabledType = $type.Substring(0, [Math]::Min(256, $type.Length))
|
|
235
|
+
if ($value -is [string]) {
|
|
236
|
+
$diagnostic.cimEnabledLength = $value.Length
|
|
237
|
+
$diagnostic.cimEnabledPreview = $value.Substring(0, [Math]::Min(256, $value.Length))
|
|
238
|
+
$diagnostic.cimEnabledPreviewTruncated = $value.Length -gt 256
|
|
239
|
+
}
|
|
240
|
+
$sid = [Security.Principal.WindowsIdentity]::GetCurrent().User.Value
|
|
241
|
+
$expectedExe = Join-Path $env:WINDIR 'System32\wscript.exe'
|
|
242
|
+
$expectedArgs = '"' + (Join-Path $installDir 'bin\trillboards-edge-task.vbs') + '" "auto-sense"'
|
|
243
|
+
$actions = @($task.Actions)
|
|
244
|
+
$owner = [string]$task.Principal.UserId
|
|
245
|
+
if ($owner -notmatch '^S-1-') { $owner = (New-Object Security.Principal.NTAccount($owner)).Translate([Security.Principal.SecurityIdentifier]).Value }
|
|
246
|
+
if ($owner -ne $sid -or $actions.Count -ne 1 -or
|
|
247
|
+
[IO.Path]::GetFullPath([string]$actions[0].Execute) -ine $expectedExe -or
|
|
248
|
+
[string]$actions[0].Arguments -cne $expectedArgs -or
|
|
249
|
+
[IO.Path]::GetFullPath([string]$actions[0].WorkingDirectory) -ine $installDir -or
|
|
250
|
+
[string]$task.State -notin @('Ready','Running','Queued','Disabled')) { throw 'Cannot verify the fresh qualification connector task' }
|
|
251
|
+
# Export only after binding this fresh, unconfigured task's owner and action.
|
|
252
|
+
$rawXml = Export-ScheduledTask -TaskName 'TrillboardsEdge' -TaskPath '\' -ErrorAction Stop
|
|
253
|
+
if ($rawXml -isnot [string]) { throw 'Unknown qualification task XML type' }
|
|
254
|
+
$diagnostic.rawTaskXml = $rawXml.Substring(0, [Math]::Min(65536, $rawXml.Length))
|
|
255
|
+
$diagnostic.rawTaskXmlTruncated = $rawXml.Length -gt 65536
|
|
256
|
+
$diagnostic.rawTaskXmlLength = $rawXml.Length
|
|
257
|
+
$xml = [xml]$rawXml
|
|
258
|
+
$namespace = $xml.DocumentElement.NamespaceURI
|
|
259
|
+
$diagnostic.namespace = $namespace.Substring(0, [Math]::Min(256, $namespace.Length))
|
|
260
|
+
$diagnostic.namespaceLength = $namespace.Length
|
|
261
|
+
if ($xml.DocumentElement.NamespaceURI -cne 'http://schemas.microsoft.com/windows/2004/02/mit/task') { throw 'Unknown qualification task definition' }
|
|
262
|
+
$ns = New-Object Xml.XmlNamespaceManager($xml.NameTable); $ns.AddNamespace('t', $xml.DocumentElement.NamespaceURI)
|
|
263
|
+
$settings = @($xml.SelectNodes('/t:Task/t:Settings', $ns))
|
|
264
|
+
$toggle = @($xml.SelectNodes('/t:Task/t:Settings/t:Enabled', $ns))
|
|
265
|
+
$principal = @($xml.SelectNodes('/t:Task/t:Principals/t:Principal/t:UserId', $ns))
|
|
266
|
+
$exec = @($xml.SelectNodes('/t:Task/t:Actions/t:Exec', $ns))
|
|
267
|
+
$diagnostic.settingsCount = $settings.Count; $diagnostic.enabledCount = $toggle.Count
|
|
268
|
+
$diagnostic.userIdCount = $principal.Count; $diagnostic.execCount = $exec.Count
|
|
269
|
+
$diagnostic.principalCount = $xml.SelectNodes('/t:Task/t:Principals/t:Principal', $ns).Count
|
|
270
|
+
$diagnostic.actionCount = $xml.SelectNodes('/t:Task/t:Actions/*', $ns).Count
|
|
271
|
+
$samples = @($toggle | Select-Object -First 2)
|
|
272
|
+
$diagnostic.xmlEnabledText = @($samples | ForEach-Object { $_.InnerText.Substring(0, [Math]::Min(256, $_.InnerText.Length)) })
|
|
273
|
+
$diagnostic.xmlEnabledLengths = @($samples | ForEach-Object { $_.InnerText.Length })
|
|
274
|
+
$diagnostic.xmlEnabledTextTruncated = $toggle.Count -gt 2 -or @($samples | Where-Object { $_.InnerText.Length -gt 256 }).Count -gt 0
|
|
275
|
+
if ($settings.Count -ne 1 -or $toggle.Count -gt 1 -or $principal.Count -ne 1 -or $exec.Count -ne 1 -or
|
|
276
|
+
$diagnostic.principalCount -ne 1 -or $diagnostic.actionCount -ne 1 -or
|
|
277
|
+
$task.Settings.Enabled -isnot [bool]) { throw 'Ambiguous qualification task definition' }
|
|
278
|
+
# The Task Scheduler settingsType schema defaults an omitted Enabled to true.
|
|
279
|
+
$xmlEnabled = $true
|
|
280
|
+
if ($toggle.Count -eq 1) {
|
|
281
|
+
try { $xmlEnabled = [Xml.XmlConvert]::ToBoolean($toggle[0].InnerText) }
|
|
282
|
+
catch { throw 'Ambiguous qualification task definition: invalid Enabled boolean' }
|
|
283
|
+
}
|
|
284
|
+
$diagnostic.effectiveXmlEnabled = $xmlEnabled
|
|
285
|
+
if ($task.Settings.Enabled -ne $xmlEnabled) { throw 'Ambiguous qualification task definition: Enabled disagreement' }
|
|
286
|
+
$xmlOwner = [string]$principal[0].InnerText
|
|
287
|
+
if ($xmlOwner -notmatch '^S-1-') { $xmlOwner = (New-Object Security.Principal.NTAccount($xmlOwner)).Translate([Security.Principal.SecurityIdentifier]).Value }
|
|
288
|
+
if ($xmlOwner -ne $sid -or [IO.Path]::GetFullPath([string]$exec[0].Command) -ine $expectedExe -or
|
|
289
|
+
[string]$exec[0].Arguments -cne $expectedArgs -or [IO.Path]::GetFullPath([string]$exec[0].WorkingDirectory) -ine $installDir) {
|
|
290
|
+
throw 'The qualification task changed during ownership inspection'
|
|
291
|
+
}
|
|
292
|
+
# Remove ONLY the mutable task-wide toggle, including its optional presence.
|
|
293
|
+
# Trigger Enabled nodes and every other definition field remain fingerprinted.
|
|
294
|
+
foreach ($node in $toggle) { [void]$node.ParentNode.RemoveChild($node) }
|
|
295
|
+
$sha = [Security.Cryptography.SHA256]::Create()
|
|
296
|
+
try { $fingerprint = [BitConverter]::ToString($sha.ComputeHash([Text.Encoding]::UTF8.GetBytes($xml.OuterXml))).Replace('-','').ToLowerInvariant() }
|
|
297
|
+
finally { $sha.Dispose() }
|
|
298
|
+
[pscustomobject]@{ Sid=$sid; Fingerprint=$fingerprint; Enabled=$task.Settings.Enabled; State=[string]$task.State }
|
|
299
|
+
} catch {
|
|
300
|
+
$failure = $_; $message = $_.Exception.Message
|
|
301
|
+
$diagnostic.failure = $message.Substring(0, [Math]::Min(1024, $message.Length))
|
|
302
|
+
$diagnostic.failureTruncated = $message.Length -gt 1024
|
|
303
|
+
try {
|
|
304
|
+
# Preserve the first refusal and any restoration refusal, without an unbounded log.
|
|
305
|
+
$path = $null
|
|
306
|
+
foreach ($index in 1..4) {
|
|
307
|
+
$candidate = Join-Path $root ('task-identity-refusal-' + $index + '.json')
|
|
308
|
+
if (-not (Test-Path -LiteralPath $candidate)) { $path = $candidate; break }
|
|
309
|
+
}
|
|
310
|
+
if (-not $path) { throw 'Task identity diagnostic limit reached' }
|
|
311
|
+
$diagnostic | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath $path -Encoding UTF8
|
|
312
|
+
} catch {
|
|
313
|
+
$message = $_.Exception.Message
|
|
314
|
+
throw ($diagnostic.failure + '; task identity diagnostic failed: ' + $message.Substring(0, [Math]::Min(1024, $message.Length)))
|
|
315
|
+
}
|
|
316
|
+
throw $failure
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
function Invoke-QualificationServiceInspection([string]$Service) {
|
|
320
|
+
& (Join-Path $installDir 'bin\stop-local-ai.ps1') -Service $Service -Inspect
|
|
321
|
+
}
|
|
322
|
+
function Get-QualificationBootstrapActors($Context) {
|
|
323
|
+
if ($null -eq $Context.AllowedHosts) {
|
|
324
|
+
$Context.AllowedHosts = @()
|
|
325
|
+
foreach ($service in @('Model','Detector')) {
|
|
326
|
+
$null = Invoke-QualificationServiceInspection $service
|
|
327
|
+
$name = if ($service -eq 'Model') { 'TrillboardsLiteRtLm' } else { 'TrillboardsDetector' }
|
|
328
|
+
$task = Get-ScheduledTask -TaskName $name -TaskPath '\' -ErrorAction Stop
|
|
329
|
+
$actions = @($task.Actions); $owner = [string]$task.Principal.UserId
|
|
330
|
+
if ($owner -notmatch '^S-1-') { $owner = (New-Object Security.Principal.NTAccount($owner)).Translate([Security.Principal.SecurityIdentifier]).Value }
|
|
331
|
+
if ($owner -ne $Context.Task.Sid -or $actions.Count -ne 1 -or
|
|
332
|
+
[IO.Path]::GetFullPath([string]$actions[0].Execute) -ine (Join-Path $env:WINDIR 'System32\wscript.exe') -or
|
|
333
|
+
-not [string]$actions[0].Arguments) { throw 'Cannot bind the installed AI host during bootstrap isolation' }
|
|
334
|
+
$Context.AllowedHosts += [pscustomobject]@{ Exe=[string]$actions[0].Execute; Args=[string]$actions[0].Arguments }
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
$root = [IO.Path]::GetFullPath($installDir).TrimEnd('\') + '\'
|
|
338
|
+
$markers = @('bin\trillboards-edge-task.vbs','bin\run-connector.ps1','bin\trillboards-edge.cmd',
|
|
339
|
+
'bin\setup-litertlm.ps1','bin\setup-detector.ps1','lib\edge-sdk\dist\cli.js') |
|
|
340
|
+
ForEach-Object { Join-Path $installDir $_ }
|
|
341
|
+
$processes = @(Get-CimInstance -ClassName Win32_Process -OperationTimeoutSec 5 -ErrorAction Stop)
|
|
342
|
+
$related = @{}
|
|
343
|
+
foreach ($process in $processes) {
|
|
344
|
+
$id = [int]$process.ProcessId
|
|
345
|
+
if ($id -eq $PID) { continue }
|
|
346
|
+
$command = [string]$process.CommandLine; $exe = [string]$process.ExecutablePath
|
|
347
|
+
if ($Context.Traced.ContainsKey($id) -or
|
|
348
|
+
($exe -and $exe.StartsWith($root, [StringComparison]::OrdinalIgnoreCase)) -or
|
|
349
|
+
$command.IndexOf($root, [StringComparison]::OrdinalIgnoreCase) -ge 0) { $related[$id] = $process }
|
|
350
|
+
}
|
|
351
|
+
# Exclude only exact registered service hosts, before tracing bootstrap children.
|
|
352
|
+
# Inspect above is authority for their service trees; a generic --wait is not.
|
|
353
|
+
foreach ($id in @($related.Keys)) {
|
|
354
|
+
$process = $related[$id]; $allowed = $false
|
|
355
|
+
$Context.Candidates[$id] = [pscustomobject]@{ ProcessId=$id; ParentProcessId=[int]$process.ParentProcessId;
|
|
356
|
+
CreationDate=[string]$process.CreationDate; Exe=[string]$process.ExecutablePath; CommandLine=[string]$process.CommandLine;
|
|
357
|
+
Sid=$null; OwnershipVerified=$false; RoleVerified=$false }
|
|
358
|
+
if ([string]$process.CommandLine -match '^(?:"[^"]+"|\S+)\s*(.*)$') {
|
|
359
|
+
$tail = $Matches[1]
|
|
360
|
+
foreach ($hostAction in $Context.AllowedHosts) {
|
|
361
|
+
if ([string]$process.ExecutablePath -ieq $hostAction.Exe -and $tail -ceq $hostAction.Args) { $allowed = $true }
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (-not $allowed) { continue }
|
|
365
|
+
if (-not $process.CreationDate) { throw 'AI host generation is unavailable' }
|
|
366
|
+
$owner = Invoke-CimMethod -InputObject $process -MethodName GetOwnerSid -OperationTimeoutSec 5 -ErrorAction Stop
|
|
367
|
+
$live = @(Get-CimInstance -ClassName Win32_Process -Filter ('ProcessId=' + $id) -OperationTimeoutSec 5 -ErrorAction Stop)
|
|
368
|
+
if ($live.Count -eq 0) { $related.Remove($id); continue }
|
|
369
|
+
if ($live.Count -ne 1 -or [string]$live[0].CreationDate -cne [string]$process.CreationDate -or
|
|
370
|
+
[string]$live[0].ExecutablePath -cne [string]$process.ExecutablePath -or [string]$live[0].CommandLine -cne [string]$process.CommandLine -or
|
|
371
|
+
$owner.ReturnValue -ne 0 -or $owner.Sid -ne $Context.Task.Sid) { throw 'AI host identity changed during bootstrap isolation' }
|
|
372
|
+
$Context.Candidates[$id].Sid = [string]$owner.Sid
|
|
373
|
+
$Context.Candidates[$id].OwnershipVerified = $true; $Context.Candidates[$id].RoleVerified = $true
|
|
374
|
+
$related.Remove($id)
|
|
375
|
+
}
|
|
376
|
+
# Descendants count only when observed beside a positively identified parent.
|
|
377
|
+
# Remember already observed children across polls; never infer a new orphan's lineage.
|
|
378
|
+
do {
|
|
379
|
+
$added = $false
|
|
380
|
+
foreach ($process in $processes) {
|
|
381
|
+
$id = [int]$process.ProcessId; $parent = [int]$process.ParentProcessId
|
|
382
|
+
if ($related.ContainsKey($id) -or $id -eq $PID) { continue }
|
|
383
|
+
if ($related.ContainsKey($parent)) { $related[$id] = $process; $added = $true }
|
|
384
|
+
elseif ($Context.Traced.ContainsKey($parent) -and -not $Context.Traced.ContainsKey($id)) {
|
|
385
|
+
throw 'A pending bootstrap descendant has unverifiable parent identity'
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
} while ($added)
|
|
389
|
+
$busy = @()
|
|
390
|
+
$ordered = @($related.Keys | Sort-Object {
|
|
391
|
+
$walk = [int]$_; $depth = 0; $seen = @{}
|
|
392
|
+
while ($related.ContainsKey($walk)) {
|
|
393
|
+
if ($seen.ContainsKey($walk)) { throw 'Bootstrap process ancestry is cyclic' }
|
|
394
|
+
$seen[$walk] = $true
|
|
395
|
+
$parent = [int]$related[$walk].ParentProcessId
|
|
396
|
+
if (-not $related.ContainsKey($parent)) { break }
|
|
397
|
+
$walk = $parent; $depth++
|
|
398
|
+
}
|
|
399
|
+
$depth
|
|
400
|
+
})
|
|
401
|
+
foreach ($id in $ordered) {
|
|
402
|
+
$process = $related[$id]
|
|
403
|
+
if (-not $Context.Candidates.ContainsKey($id)) {
|
|
404
|
+
$Context.Candidates[$id] = [pscustomobject]@{ ProcessId=$id; ParentProcessId=[int]$process.ParentProcessId;
|
|
405
|
+
CreationDate=[string]$process.CreationDate; Exe=[string]$process.ExecutablePath; CommandLine=[string]$process.CommandLine;
|
|
406
|
+
Sid=$null; OwnershipVerified=$false; RoleVerified=$false }
|
|
407
|
+
}
|
|
408
|
+
if (-not $process.CreationDate -or -not $process.ExecutablePath -or -not $process.CommandLine) { throw 'Bootstrap actor identity is unavailable' }
|
|
409
|
+
$identity = [string]$process.CreationDate + '|' + [string]$process.ExecutablePath + '|' + [string]$process.CommandLine
|
|
410
|
+
if ($Context.Traced.ContainsKey($id) -and $Context.Traced[$id] -cne $identity) { throw 'A bootstrap PID was replaced during isolation' }
|
|
411
|
+
try { $owner = Invoke-CimMethod -InputObject $process -MethodName GetOwnerSid -OperationTimeoutSec 5 -ErrorAction Stop }
|
|
412
|
+
catch {
|
|
413
|
+
$remaining = @(Get-CimInstance -ClassName Win32_Process -Filter ('ProcessId=' + $id) -OperationTimeoutSec 5 -ErrorAction Stop)
|
|
414
|
+
if ($remaining.Count -eq 0) { continue }
|
|
415
|
+
throw
|
|
416
|
+
}
|
|
417
|
+
$live = @(Get-CimInstance -ClassName Win32_Process -Filter ('ProcessId=' + $id) -OperationTimeoutSec 5 -ErrorAction Stop)
|
|
418
|
+
if ($live.Count -eq 0) { continue }
|
|
419
|
+
if ($live.Count -ne 1 -or
|
|
420
|
+
([string]$live[0].CreationDate + '|' + [string]$live[0].ExecutablePath + '|' + [string]$live[0].CommandLine) -cne $identity) {
|
|
421
|
+
throw 'Bootstrap actor changed during owner inspection'
|
|
422
|
+
}
|
|
423
|
+
if ($owner.ReturnValue -ne 0 -or $owner.Sid -ne $Context.Task.Sid) { throw 'A related bootstrap actor has foreign or unknown ownership' }
|
|
424
|
+
$Context.Candidates[$id].Sid = [string]$owner.Sid; $Context.Candidates[$id].OwnershipVerified = $true
|
|
425
|
+
$knownRoot = @($markers | Where-Object { ([string]$process.CommandLine).IndexOf($_, [StringComparison]::OrdinalIgnoreCase) -ge 0 }).Count -gt 0
|
|
426
|
+
$knownChild = $Context.Traced.ContainsKey($id) -or
|
|
427
|
+
($related.ContainsKey([int]$process.ParentProcessId) -and $Context.Traced.ContainsKey([int]$process.ParentProcessId))
|
|
428
|
+
if ($related.ContainsKey([int]$process.ParentProcessId) -and
|
|
429
|
+
[DateTime]$process.CreationDate -lt [DateTime]$related[[int]$process.ParentProcessId].CreationDate) { throw 'Bootstrap parent generation is unverifiable' }
|
|
430
|
+
$exe = [IO.Path]::GetFullPath([string]$process.ExecutablePath)
|
|
431
|
+
# Windows creates this console child for the observed setup PowerShell host.
|
|
432
|
+
# It stays BUSY until natural exit; a root-marker/orphan or lookalike is not authority.
|
|
433
|
+
$consoleChild = [string]$process.Name -ieq 'conhost.exe'
|
|
434
|
+
if (($consoleChild -and (-not $knownChild -or $exe -ine (Join-Path $env:WINDIR 'System32\conhost.exe'))) -or
|
|
435
|
+
(-not $consoleChild -and ((-not $knownRoot -and -not $knownChild) -or [string]$process.Name -notin
|
|
436
|
+
@('powershell.exe','cmd.exe','wscript.exe','node.exe','uv.exe','python.exe','pythonw.exe','litert-lm.exe','trillboards-detector.exe','curl.exe')))) {
|
|
437
|
+
throw 'An unknown process belongs to the qualification bootstrap'
|
|
438
|
+
}
|
|
439
|
+
$windowsExe = @('System32\cmd.exe','SysWOW64\cmd.exe','System32\wscript.exe','SysWOW64\wscript.exe',
|
|
440
|
+
'System32\WindowsPowerShell\v1.0\powershell.exe','SysWOW64\WindowsPowerShell\v1.0\powershell.exe','System32\curl.exe','System32\conhost.exe') |
|
|
441
|
+
ForEach-Object { Join-Path $env:WINDIR $_ }
|
|
442
|
+
$userTool = $exe.StartsWith((Join-Path $env:USERPROFILE '.local\bin\'), [StringComparison]::OrdinalIgnoreCase) -or
|
|
443
|
+
$exe.StartsWith((Join-Path $env:APPDATA 'uv\'), [StringComparison]::OrdinalIgnoreCase) -or
|
|
444
|
+
$exe.StartsWith((Join-Path $env:LOCALAPPDATA 'uv\'), [StringComparison]::OrdinalIgnoreCase)
|
|
445
|
+
if ([IO.Path]::GetFileName($exe) -ine [string]$process.Name -or
|
|
446
|
+
(-not ($windowsExe -icontains $exe) -and -not $exe.StartsWith($root, [StringComparison]::OrdinalIgnoreCase) -and -not $userTool)) {
|
|
447
|
+
throw 'The bootstrap actor executable is outside its owned runtime'
|
|
448
|
+
}
|
|
449
|
+
$Context.Traced[$id] = $identity
|
|
450
|
+
$Context.Candidates[$id].RoleVerified = $true
|
|
451
|
+
$Context.OwnedActors[$id] = $Context.Candidates[$id]
|
|
452
|
+
$busy += $Context.OwnedActors[$id]
|
|
453
|
+
}
|
|
454
|
+
return $busy
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
function Wait-QualificationModelReady($Evidence, $BootstrapContext = $null) {
|
|
459
|
+
$started = Get-QualificationClockSeconds
|
|
460
|
+
if ($null -ne $BootstrapContext -and $null -ne $BootstrapContext.FirstStarted) {
|
|
461
|
+
$started = [double]$BootstrapContext.FirstStarted
|
|
462
|
+
$Evidence.startedAtUtc = $BootstrapContext.FirstStartedAtUtc
|
|
463
|
+
$BootstrapContext.FirstStarted = $null
|
|
464
|
+
}
|
|
465
|
+
$barrier = New-QualificationSetupBarrier
|
|
466
|
+
try {
|
|
467
|
+
while (((Get-QualificationClockSeconds) - $started) -lt 120) {
|
|
468
|
+
$held = $false
|
|
469
|
+
try {
|
|
470
|
+
$bootstrapReady = $true
|
|
471
|
+
if ($null -ne $BootstrapContext) {
|
|
472
|
+
$task = Get-QualificationConnectorTaskState
|
|
473
|
+
if ($task.Fingerprint -cne $BootstrapContext.Task.Fingerprint -or $task.Enabled) { throw 'Bootstrap ownership or disabled state changed during drain' }
|
|
474
|
+
$actors = @(Get-QualificationBootstrapActors $BootstrapContext)
|
|
475
|
+
$Evidence.bootstrapActors = $actors
|
|
476
|
+
$bootstrapReady = $task.State -notin @('Running','Queued') -and $actors.Count -eq 0 -and ((Get-QualificationClockSeconds) - $started) -lt 120
|
|
477
|
+
}
|
|
478
|
+
if ($bootstrapReady) {
|
|
479
|
+
try { $held = $barrier.WaitOne(0) } catch [Threading.AbandonedMutexException] { $held = $true; $Evidence.abandonedSetupOwner = $true }
|
|
480
|
+
if ($held) {
|
|
481
|
+
$Evidence.setupBarrierAcquired = $true
|
|
482
|
+
$snapshot = Get-QualificationModelSnapshot
|
|
483
|
+
$Evidence.lastReadinessSnapshot = $snapshot
|
|
484
|
+
if ($snapshot.ready -and ((Get-QualificationClockSeconds) - $started) -lt 120) { return $snapshot }
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
} finally { if ($held) { $barrier.ReleaseMutex() } }
|
|
488
|
+
$remaining = 120 - ((Get-QualificationClockSeconds) - $started)
|
|
489
|
+
if ($remaining -gt 0) { Start-Sleep -Milliseconds ([int][Math]::Min(2000, [Math]::Ceiling($remaining * 1000))) }
|
|
490
|
+
}
|
|
491
|
+
throw 'The owned verified model configuration did not become ready within the existing 120-second deadline'
|
|
492
|
+
} finally { $Evidence.readinessSeconds = (Get-QualificationClockSeconds) - $started; $barrier.Dispose() }
|
|
493
|
+
}
|
|
494
|
+
function Test-QualificationSetupIdle {
|
|
495
|
+
$barrier = New-QualificationSetupBarrier
|
|
496
|
+
$held = $false
|
|
497
|
+
try {
|
|
498
|
+
try { $held = $barrier.WaitOne(0) } catch [Threading.AbandonedMutexException] { $held = $true }
|
|
499
|
+
return $held
|
|
500
|
+
} finally { if ($held) { $barrier.ReleaseMutex() }; $barrier.Dispose() }
|
|
501
|
+
}
|
|
502
|
+
function Assert-QualificationRuntimeProof($Answer, [string]$InferenceModel, [string]$Sha256) {
|
|
503
|
+
$property = $Answer.PSObject.Properties['runtimeModel']
|
|
504
|
+
if ($null -eq $property -or $null -eq $property.Value) { throw 'The person response lacks native runtime model proof' }
|
|
505
|
+
$proof = $property.Value
|
|
506
|
+
if ((@($proof.PSObject.Properties.Name | Sort-Object) -join ',') -cne 'format,runtimeModelId,sha256,version' -or
|
|
507
|
+
$proof.version -ne 1 -or $proof.format -cne 'litert-lm' -or $proof.sha256 -cne $Sha256 -or $proof.runtimeModelId -cne $InferenceModel) {
|
|
508
|
+
throw 'The person response did not execute the selected artifact/backend'
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
function Assert-RestartImageInference([string]$ServiceName) {
|
|
512
|
+
$evidence = [ordered]@{ service = $ServiceName; passed = $false; phase = 'setup-completion'; setupBarrierAcquired = $false;
|
|
513
|
+
startedAtUtc = [DateTimeOffset]::UtcNow.ToString('o'); readinessDeadlineSeconds = 120; personTimeoutSeconds = 240;
|
|
514
|
+
backendStandardError = @{ available = $false; reason = 'The installed Windows hidden model task discards stdout/stderr; see register-litertlm-task.ps1:30-41. Available provisioner logs are retained separately.' } }
|
|
515
|
+
$receipt.serviceRestartChecks += $evidence
|
|
516
|
+
try {
|
|
517
|
+
# Setup completion is a barrier only. The customer client takes no setup lock.
|
|
518
|
+
$ready = Wait-QualificationModelReady $evidence
|
|
519
|
+
$evidence.phase = 'detector-readiness'
|
|
520
|
+
Wait-DetectorAnswer
|
|
521
|
+
Assert-HiddenTask 'TrillboardsLiteRtLm'; Assert-HiddenTask 'TrillboardsDetector'
|
|
522
|
+
$evidence.phase = 'before-person-inference'
|
|
523
|
+
$evidence.setupIdleBeforeInference = Test-QualificationSetupIdle
|
|
524
|
+
if (-not $evidence.setupIdleBeforeInference) { throw 'Model setup became active before acceptance inference' }
|
|
525
|
+
$evidence.beforeInference = Get-QualificationModelSnapshot
|
|
526
|
+
Assert-QualificationModelGeneration $ready $evidence.beforeInference
|
|
527
|
+
$evidence.phase = 'person-inference'
|
|
528
|
+
Assert-ImageInference -InferenceModel $ready.inferenceModel -ExpectedModelSha256 'ab7838cdfc8f77e54d8ca45eadceb20452d9f01e4bfade03e5dce27911b27e42' -Evidence $evidence
|
|
529
|
+
$evidence.phase = 'after-person-inference'
|
|
530
|
+
$evidence.afterInference = Get-QualificationModelSnapshot
|
|
531
|
+
$evidence.setupIdleAfterInference = Test-QualificationSetupIdle
|
|
532
|
+
if (-not $evidence.setupIdleAfterInference) { throw 'Model setup became active during acceptance inference' }
|
|
533
|
+
Assert-QualificationModelGeneration $evidence.beforeInference $evidence.afterInference
|
|
534
|
+
$evidence.passed = $true; $evidence.phase = 'complete'
|
|
535
|
+
} catch {
|
|
536
|
+
$evidence.failure = $_.Exception.Message
|
|
537
|
+
$evidence.failureType = $_.Exception.GetType().FullName
|
|
538
|
+
$evidence.failureId = $_.FullyQualifiedErrorId
|
|
539
|
+
$evidence.failureStack = $_.ScriptStackTrace
|
|
540
|
+
try { $evidence.afterFailure = Get-QualificationModelSnapshot } catch { $evidence.afterFailureError = $_.Exception.Message }
|
|
541
|
+
throw
|
|
542
|
+
} finally {
|
|
543
|
+
$evidence.completedAtUtc = [DateTimeOffset]::UtcNow.ToString('o')
|
|
544
|
+
$evidence | ConvertTo-Json -Depth 16 | Set-Content -LiteralPath (Join-Path $root ('restart-' + $ServiceName + '.json'))
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
function Invoke-QualificationServiceRestarts {
|
|
550
|
+
# This is an isolated fresh-install AI test, not a paired sensing restart.
|
|
551
|
+
# Capture restoration authority before the first write; never stop a setup actor.
|
|
552
|
+
$bootstrapContext = [ordered]@{ Task=$null; AllowedHosts=$null; Traced=@{}; Candidates=@{}; OwnedActors=@{}; FirstStarted=(Get-QualificationClockSeconds); FirstStartedAtUtc=[DateTimeOffset]::UtcNow.ToString('o') }
|
|
553
|
+
$receipt.bootstrapIsolation = [ordered]@{ isolatedFreshAiOnly=$true; disabledVerified=$false; holdFailure=$null; afterRestarts=@(); restored=$false }
|
|
554
|
+
$failure = $null; $restoreFailure = $null
|
|
555
|
+
try {
|
|
556
|
+
if (Test-Path -LiteralPath (Join-Path $installDir 'trillboards.config.json')) { throw 'Bootstrap isolation refuses a configured connector' }
|
|
557
|
+
$bootstrapContext.Task = Get-QualificationConnectorTaskState
|
|
558
|
+
if (((Get-QualificationClockSeconds) - $bootstrapContext.FirstStarted) -ge 120) { throw 'Bootstrap inspection exceeded the existing 120-second readiness deadline' }
|
|
559
|
+
$receipt.bootstrapIsolation.originalEnabled = $bootstrapContext.Task.Enabled
|
|
560
|
+
$receipt.bootstrapIsolation.taskFingerprint = $bootstrapContext.Task.Fingerprint
|
|
561
|
+
if ($bootstrapContext.Task.Enabled) {
|
|
562
|
+
Disable-ScheduledTask -TaskName 'TrillboardsEdge' -TaskPath '\' -ErrorAction Stop | Out-Null
|
|
563
|
+
}
|
|
564
|
+
$disabled = Get-QualificationConnectorTaskState
|
|
565
|
+
if ($disabled.Fingerprint -cne $bootstrapContext.Task.Fingerprint -or $disabled.Enabled) { throw 'The owned bootstrap task did not remain unchanged and disabled' }
|
|
566
|
+
$receipt.bootstrapIsolation.disabledVerified = $true
|
|
567
|
+
$powershell = Join-Path $env:WINDIR 'System32\WindowsPowerShell\v1.0\powershell.exe'
|
|
568
|
+
foreach ($service in @(@{ Name = 'Model'; Task = 'TrillboardsLiteRtLm' }, @{ Name = 'Detector'; Task = 'TrillboardsDetector' })) {
|
|
569
|
+
$preStop = [ordered]@{ service = $service.Name; phase = 'before-stop-setup-completion'; passed = $false;
|
|
570
|
+
setupBarrierAcquired = $false; startedAtUtc = [DateTimeOffset]::UtcNow.ToString('o'); readinessDeadlineSeconds = 120 }
|
|
571
|
+
$receipt.serviceRestartPreparationChecks += $preStop
|
|
572
|
+
try {
|
|
573
|
+
# Completion precondition only; the existing waiter releases the mutex before stop/start.
|
|
574
|
+
$preStop.snapshot = Wait-QualificationModelReady $preStop $bootstrapContext
|
|
575
|
+
$preStop.passed = $true
|
|
576
|
+
} catch {
|
|
577
|
+
$preStop.failure = $_.Exception.Message
|
|
578
|
+
throw
|
|
579
|
+
} finally {
|
|
580
|
+
$preStop.completedAtUtc = [DateTimeOffset]::UtcNow.ToString('o')
|
|
581
|
+
}
|
|
582
|
+
$null = Invoke-QualificationProcess -File $powershell -Arguments @('-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-File',
|
|
583
|
+
(Join-Path $installDir 'bin\stop-local-ai.ps1'), '-Service', $service.Name) -LogName ('stop-' + $service.Name + '.log') -TimeoutSeconds 90
|
|
584
|
+
Enable-ScheduledTask -TaskName $service.Task -TaskPath '\' -ErrorAction Stop | Out-Null
|
|
585
|
+
Start-ScheduledTask -TaskName $service.Task -TaskPath '\' -ErrorAction Stop
|
|
586
|
+
Assert-RestartImageInference -ServiceName $service.Name
|
|
587
|
+
if ($null -ne $bootstrapContext) {
|
|
588
|
+
$heldTask = Get-QualificationConnectorTaskState
|
|
589
|
+
$receipt.bootstrapIsolation.afterRestarts += [ordered]@{ service=$service.Name; atUtc=[DateTimeOffset]::UtcNow.ToString('o');
|
|
590
|
+
fingerprint=$heldTask.Fingerprint; enabled=$heldTask.Enabled; state=$heldTask.State }
|
|
591
|
+
if ($heldTask.Fingerprint -cne $bootstrapContext.Task.Fingerprint -or $heldTask.Enabled) {
|
|
592
|
+
$receipt.bootstrapIsolation.holdFailure = 'Bootstrap isolation was lost during restart acceptance'
|
|
593
|
+
throw $receipt.bootstrapIsolation.holdFailure
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
} catch {
|
|
598
|
+
$failure = $_
|
|
599
|
+
$receipt.bootstrapIsolation.failure = $_.Exception.Message
|
|
600
|
+
} finally {
|
|
601
|
+
$receipt.bootstrapIsolation.actorCandidates = @($bootstrapContext.Candidates.Values)
|
|
602
|
+
$receipt.bootstrapIsolation.ownedActorsSeen = @($bootstrapContext.OwnedActors.Values)
|
|
603
|
+
if ($null -ne $bootstrapContext.Task) {
|
|
604
|
+
try {
|
|
605
|
+
$current = Get-QualificationConnectorTaskState
|
|
606
|
+
if ($current.Fingerprint -cne $bootstrapContext.Task.Fingerprint) { throw 'The connector task was replaced; its enabled state was not changed' }
|
|
607
|
+
if ($receipt.bootstrapIsolation.disabledVerified -and $current.Enabled) {
|
|
608
|
+
if ($null -eq $receipt.bootstrapIsolation.holdFailure) { $receipt.bootstrapIsolation.holdFailure = 'Bootstrap isolation was lost before restoration' }
|
|
609
|
+
if ($null -eq $failure) {
|
|
610
|
+
$failure = [InvalidOperationException]::new($receipt.bootstrapIsolation.holdFailure)
|
|
611
|
+
$receipt.bootstrapIsolation.failure = $receipt.bootstrapIsolation.holdFailure
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
if ($current.Enabled -ne $bootstrapContext.Task.Enabled) {
|
|
615
|
+
if ($bootstrapContext.Task.Enabled) { Enable-ScheduledTask -TaskName 'TrillboardsEdge' -TaskPath '\' -ErrorAction Stop | Out-Null }
|
|
616
|
+
else { Disable-ScheduledTask -TaskName 'TrillboardsEdge' -TaskPath '\' -ErrorAction Stop | Out-Null }
|
|
617
|
+
}
|
|
618
|
+
$restored = Get-QualificationConnectorTaskState
|
|
619
|
+
if ($restored.Fingerprint -cne $bootstrapContext.Task.Fingerprint -or $restored.Enabled -ne $bootstrapContext.Task.Enabled) { throw 'The owned connector enabled state did not restore' }
|
|
620
|
+
$receipt.bootstrapIsolation.restored = $true
|
|
621
|
+
} catch {
|
|
622
|
+
$restoreFailure = $_
|
|
623
|
+
$receipt.bootstrapIsolation.restoreFailure = $_.Exception.Message
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
# Preserve both diagnostics, and retain the original failure when both occurred.
|
|
628
|
+
if ($null -ne $failure) { throw $failure }
|
|
629
|
+
if ($null -ne $restoreFailure) { throw $restoreFailure }
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
|
|
154
633
|
try {
|
|
155
634
|
if ([bool]$CustomerPackagePath -ne [bool]$ManifestPath) { throw 'Candidate package and manifest paths must be provided together' }
|
|
156
635
|
$localCandidate = [bool]$CustomerPackagePath
|
|
@@ -220,17 +699,9 @@ try {
|
|
|
220
699
|
Wait-ModelReady; Wait-DetectorAnswer
|
|
221
700
|
$receipt.phase = 'repeat-install-inference'
|
|
222
701
|
Assert-ImageInference
|
|
223
|
-
$receipt.repeatInstallPassed = $true; $receipt.phase = 'service-restart'
|
|
224
|
-
$
|
|
225
|
-
|
|
226
|
-
$null = Invoke-QualificationProcess -File $powershell -Arguments @('-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-File',
|
|
227
|
-
(Join-Path $installDir 'bin\stop-local-ai.ps1'), '-Service', $service.Name) -LogName ('stop-' + $service.Name + '.log') -TimeoutSeconds 90
|
|
228
|
-
Enable-ScheduledTask -TaskName $service.Task -TaskPath '\' -ErrorAction Stop | Out-Null
|
|
229
|
-
Start-ScheduledTask -TaskName $service.Task -TaskPath '\' -ErrorAction Stop
|
|
230
|
-
Wait-ModelReady; Wait-DetectorAnswer
|
|
231
|
-
Assert-HiddenTask 'TrillboardsLiteRtLm'; Assert-HiddenTask 'TrillboardsDetector'
|
|
232
|
-
Assert-ImageInference
|
|
233
|
-
}
|
|
702
|
+
$receipt.repeatInstallPassed = $true; $receipt.phase = 'service-restart'; $receipt.serviceRestartChecks = @()
|
|
703
|
+
$receipt.serviceRestartPreparationChecks = @()
|
|
704
|
+
Invoke-QualificationServiceRestarts
|
|
234
705
|
$receipt.serviceRestartPassed = $true; $receipt.phase = 'uninstall'
|
|
235
706
|
$receipt.uninstallerSha256 = Invoke-InstalledUninstaller -InstallDir $installDir -RunRoot $root -InheritPowerShellModulePath:($PowerShellModuleEnvironment -eq 'Inherited')
|
|
236
707
|
foreach ($name in $taskNames) {
|
|
@@ -250,7 +721,7 @@ try {
|
|
|
250
721
|
if (Test-Path -LiteralPath $logDir -PathType Container) { Copy-Item -LiteralPath $logDir -Destination (Join-Path $root 'product-logs') -Recurse -Force }
|
|
251
722
|
} catch { Write-Warning ('Some product logs could not be copied: ' + $_.Exception.Message) }
|
|
252
723
|
$receipt.completedAtUtc = [DateTimeOffset]::UtcNow.ToString('o')
|
|
253
|
-
$receipt | ConvertTo-Json -Depth
|
|
724
|
+
$receipt | ConvertTo-Json -Depth 20 | Set-Content -LiteralPath (Join-Path $root 'qualification.json')
|
|
254
725
|
if ($env:GITHUB_OUTPUT) { ('artifact_path=' + $root) | Out-File -LiteralPath $env:GITHUB_OUTPUT -Append -Encoding utf8 }
|
|
255
|
-
$receipt | ConvertTo-Json -Depth
|
|
726
|
+
$receipt | ConvertTo-Json -Depth 20
|
|
256
727
|
}
|
|
@@ -76,7 +76,10 @@ function Resolve-DetectorSource {
|
|
|
76
76
|
# and a matching package version do not prove the detector can even import.
|
|
77
77
|
function Ensure-DetectorNativeRuntime {
|
|
78
78
|
$required = @('vcruntime140.dll','vcruntime140_1.dll','msvcp140.dll')
|
|
79
|
-
|
|
79
|
+
# The NSIS installer is 32-bit: its System32 view is redirected to SysWOW64.
|
|
80
|
+
# Inspect the native x64 DLLs through Sysnative in that process only.
|
|
81
|
+
$nativeSystemDirectory = if ([Environment]::Is64BitOperatingSystem -and -not [Environment]::Is64BitProcess) { 'Sysnative' } else { 'System32' }
|
|
82
|
+
$missing = @($required | Where-Object { -not (Test-Path -LiteralPath (Join-Path $env:WINDIR ($nativeSystemDirectory + '\' + $_))) })
|
|
80
83
|
if (-not $missing.Count) { return }
|
|
81
84
|
Log 'Installing the missing Microsoft x64 C++ runtime required by the local detector'
|
|
82
85
|
$runtimeDirectory = [IO.Path]::GetFullPath((Join-Path $env:TEMP ('trillboards-detector-vc-' + [Guid]::NewGuid().ToString('N'))))
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* The detector service's `detection_colors` task: the share of each confident
|
|
3
3
|
* person box whose pixels are a requested colour, measured on the original
|
|
4
4
|
* frame with Pillow's 8-bit HSV (deploy/detector/trillboards_detector/colors.py).
|
|
5
|
-
* No model
|
|
6
|
-
*
|
|
5
|
+
* No model, garment classification or decision: the connector applies the
|
|
6
|
+
* declared method to the measured colour share.
|
|
7
7
|
*/
|
|
8
|
-
export interface
|
|
8
|
+
export interface DetectionColorsV1Request {
|
|
9
9
|
version: 1;
|
|
10
10
|
minScore: number;
|
|
11
11
|
maxBoxes: number;
|
|
@@ -13,8 +13,15 @@ export interface DetectionColorsRequest {
|
|
|
13
13
|
minSaturation: number;
|
|
14
14
|
minValue: number;
|
|
15
15
|
}
|
|
16
|
+
/** Version 2 bounds achromatic and other selected colours without changing v1. */
|
|
17
|
+
export interface DetectionColorsV2Request extends Omit<DetectionColorsV1Request, 'version'> {
|
|
18
|
+
version: 2;
|
|
19
|
+
maxSaturation: number;
|
|
20
|
+
maxValue: number;
|
|
21
|
+
}
|
|
22
|
+
export type DetectionColorsRequest = DetectionColorsV1Request | DetectionColorsV2Request;
|
|
16
23
|
export interface DetectionColorsResult {
|
|
17
|
-
version: 1;
|
|
24
|
+
version: 1 | 2;
|
|
18
25
|
imageSha256: string;
|
|
19
26
|
frameSize: {
|
|
20
27
|
width: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DetectionColors.d.ts","sourceRoot":"","sources":["../src/DetectionColors.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"DetectionColors.d.ts","sourceRoot":"","sources":["../src/DetectionColors.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAC,CAAC,CAAC;IAAC,QAAQ,EAAC,MAAM,CAAC;IAAC,QAAQ,EAAC,MAAM,CAAC;IAC5C,GAAG,EAAC,KAAK,CAAC,CAAC,MAAM,EAAC,MAAM,CAAC,CAAC,CAAC;IAAC,aAAa,EAAC,MAAM,CAAC;IAAC,QAAQ,EAAC,MAAM,CAAC;CACnE;AACD,kFAAkF;AAClF,MAAM,WAAW,wBAAyB,SAAQ,IAAI,CAAC,wBAAwB,EAAC,SAAS,CAAC;IACxF,OAAO,EAAC,CAAC,CAAC;IAAC,aAAa,EAAC,MAAM,CAAC;IAAC,QAAQ,EAAC,MAAM,CAAC;CAClD;AACD,MAAM,MAAM,sBAAsB,GAAC,wBAAwB,GAAC,wBAAwB,CAAC;AACrF,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAC,CAAC,GAAC,CAAC,CAAC;IAAC,WAAW,EAAC,MAAM,CAAC;IAAC,SAAS,EAAC;QAAC,KAAK,EAAC,MAAM,CAAC;QAAA,MAAM,EAAC,MAAM,CAAA;KAAC,CAAC;IACxE,OAAO,EAAC,sBAAsB,CAAC;IAC/B,MAAM,EAAC,KAAK,CAAC;QAAC,cAAc,EAAC,MAAM,CAAC;QAAA,QAAQ,EAAC,MAAM,CAAA;KAAC,CAAC,CAAC;CACvD;AACD,eAAO,MAAM,eAAe,KAAG,CAAC;AAKhC,wBAAgB,8BAA8B,CAAC,KAAK,EAAC,OAAO,GAAE,sBAAsB,CAanF;AAED,+FAA+F;AAC/F,wBAAgB,eAAe,CAAC,UAAU,EAAC,aAAa,CAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAA,UAAU,EAAC,MAAM,CAAA;CAAC,CAAC,EACxF,OAAO,EAAC,sBAAsB,GAAE,MAAM,EAAE,CAKzC;AAED,sFAAsF;AACtF,wBAAgB,0BAA0B,CAAC,KAAK,EAAC,OAAO,EAAC,OAAO,EAAC,sBAAsB,EAAC,IAAI,EAAC,MAAM,EACjG,YAAY,EAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAA,MAAM,EAAC,MAAM,CAAA;CAAC,EAAC,UAAU,EAAC,aAAa,CAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAA,UAAU,EAAC,MAAM,CAAA;CAAC,CAAC,GAAE,qBAAqB,CAe5H"}
|
package/dist/DetectionColors.js
CHANGED
|
@@ -12,10 +12,13 @@ const finite = (v) => typeof v === 'number' && Number.isFinite(v);
|
|
|
12
12
|
const byte = (v) => Number.isSafeInteger(v) && v >= 0 && v <= 255;
|
|
13
13
|
function validateDetectionColorsRequest(value) {
|
|
14
14
|
const v = value;
|
|
15
|
-
if (!keys(v, 'hue,maxBoxes,minSaturation,minScore,minValue,version'
|
|
15
|
+
if (!keys(v, v?.version === 2 ? 'hue,maxBoxes,maxSaturation,maxValue,minSaturation,minScore,minValue,version'
|
|
16
|
+
: 'hue,maxBoxes,minSaturation,minScore,minValue,version') || (v.version !== 1 && v.version !== 2)
|
|
16
17
|
|| !finite(v.minScore) || v.minScore <= 0 || v.minScore > 1
|
|
17
18
|
|| !Number.isSafeInteger(v.maxBoxes) || v.maxBoxes < 1 || v.maxBoxes > exports.MAX_COLOR_BOXES
|
|
18
19
|
|| !byte(v.minSaturation) || !byte(v.minValue)
|
|
20
|
+
|| v.version === 2 && (!byte(v.maxSaturation) || v.maxSaturation < v.minSaturation
|
|
21
|
+
|| !byte(v.maxValue) || v.maxValue < v.minValue)
|
|
19
22
|
|| !Array.isArray(v.hue) || v.hue.length < 1 || v.hue.length > 4
|
|
20
23
|
|| v.hue.some(r => !Array.isArray(r) || r.length !== 2 || !byte(r[0]) || !byte(r[1]) || r[0] > r[1]))
|
|
21
24
|
throw Error('Invalid detection colour request');
|
|
@@ -32,7 +35,7 @@ function colorBoxIndices(detections, request) {
|
|
|
32
35
|
function parseDetectionColorsResult(value, request, jpeg, originalSize, detections) {
|
|
33
36
|
validateDetectionColorsRequest(request);
|
|
34
37
|
const v = value;
|
|
35
|
-
if (!keys(v, 'frameSize,imageSha256,people,request,version') || v.version !==
|
|
38
|
+
if (!keys(v, 'frameSize,imageSha256,people,request,version') || v.version !== request.version
|
|
36
39
|
|| v.imageSha256 !== (0, crypto_1.createHash)('sha256').update(jpeg).digest('hex')
|
|
37
40
|
|| !keys(v.frameSize, 'height,width') || v.frameSize.width !== originalSize.width
|
|
38
41
|
|| v.frameSize.height !== originalSize.height || !(0, util_1.isDeepStrictEqual)(v.request, request)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DetectionColors.js","sourceRoot":"","sources":["../src/DetectionColors.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"DetectionColors.js","sourceRoot":"","sources":["../src/DetectionColors.ts"],"names":[],"mappings":";;;AA6BA,wEAaC;AAG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