@trillboards/edge-sdk 0.2.159 → 0.2.165

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.
Files changed (51) hide show
  1. package/deploy/macos/TrillboardsSetupApp.m +36 -0
  2. package/deploy/macos/pair.command +13 -0
  3. package/deploy/windows/README.md +17 -0
  4. package/deploy/windows/ci/test-local-ai-diagnostic.ps1 +213 -0
  5. package/deploy/windows/ci/test-published-install.ps1 +243 -0
  6. package/deploy/windows/e2e/test-local-sense.ps1 +32 -3
  7. package/deploy/windows/installer.nsi +12 -0
  8. package/deploy/windows/setup-detector.ps1 +20 -42
  9. package/deploy/windows/setup-litertlm.ps1 +126 -37
  10. package/deploy/windows/stop-local-ai.ps1 +122 -4
  11. package/deploy/windows/trillboards-pair.cmd +8 -0
  12. package/deploy/windows/trillboards-setup.ps1 +68 -17
  13. package/dist/EdgeAgent.js +1 -1
  14. package/dist/InstallerOnboardingClient.d.ts +1 -0
  15. package/dist/InstallerOnboardingClient.d.ts.map +1 -1
  16. package/dist/InstallerOnboardingClient.js +10 -0
  17. package/dist/InstallerOnboardingClient.js.map +1 -1
  18. package/dist/LiteRtVlmProvider.d.ts +6 -3
  19. package/dist/LiteRtVlmProvider.d.ts.map +1 -1
  20. package/dist/LiteRtVlmProvider.js +12 -5
  21. package/dist/LiteRtVlmProvider.js.map +1 -1
  22. package/dist/SetupSessionClient.d.ts +5 -0
  23. package/dist/SetupSessionClient.d.ts.map +1 -1
  24. package/dist/SetupSessionClient.js +1 -0
  25. package/dist/SetupSessionClient.js.map +1 -1
  26. package/dist/autoSense.d.ts +10 -1
  27. package/dist/autoSense.d.ts.map +1 -1
  28. package/dist/autoSense.js +135 -5
  29. package/dist/autoSense.js.map +1 -1
  30. package/dist/cli.d.ts.map +1 -1
  31. package/dist/cli.js +24 -1
  32. package/dist/cli.js.map +1 -1
  33. package/dist/connectorCameraSetup.d.ts +26 -0
  34. package/dist/connectorCameraSetup.d.ts.map +1 -0
  35. package/dist/connectorCameraSetup.js +225 -0
  36. package/dist/connectorCameraSetup.js.map +1 -0
  37. package/dist/diagnose.d.ts +1 -1
  38. package/dist/diagnose.js +1 -1
  39. package/dist/installerOnboardingMode.d.ts +1 -0
  40. package/dist/installerOnboardingMode.d.ts.map +1 -1
  41. package/dist/installerOnboardingMode.js +25 -5
  42. package/dist/installerOnboardingMode.js.map +1 -1
  43. package/dist/setupMode.d.ts +38 -0
  44. package/dist/setupMode.d.ts.map +1 -1
  45. package/dist/setupMode.js +217 -49
  46. package/dist/setupMode.js.map +1 -1
  47. package/dist/setupProgress.d.ts +1 -0
  48. package/dist/setupProgress.d.ts.map +1 -1
  49. package/dist/setupProgress.js +2 -0
  50. package/dist/setupProgress.js.map +1 -1
  51. package/package.json +1 -1
@@ -99,6 +99,7 @@ static BOOL acquireSetupInstanceLock(void) {
99
99
  @property(nonatomic, assign) BOOL setupStarted;
100
100
  @property(nonatomic, assign) BOOL terminating;
101
101
  @property(nonatomic, assign) BOOL signingIn;
102
+ @property(nonatomic, assign) BOOL authorizationOnly;
102
103
  @end
103
104
 
104
105
  @implementation TrillboardsSetupDelegate
@@ -965,6 +966,9 @@ static BOOL acquireSetupInstanceLock(void) {
965
966
  NSNumber *devices = state[@"devicesFound"];
966
967
  NSNumber *rejected = state[@"rejectedFeeds"];
967
968
  if ([stage isEqualToString:@"onboarding_account"]) {
969
+ self.authorizationOnly = [state[@"authorizationOnly"] isEqual:@YES];
970
+ if (self.authorizationOnly && !self.signingIn) [self authModePressed];
971
+ self.authModeButton.hidden = self.authorizationOnly;
968
972
  [self showOnboardingPanel:self.accountPanel];
969
973
  [self updateSteps:1];
970
974
  self.accountSubmit.enabled = YES;
@@ -1148,8 +1152,11 @@ static BOOL acquireSetupInstanceLock(void) {
1148
1152
 
1149
1153
  - (void)updateSteps:(NSInteger)active {
1150
1154
  NSArray<NSString *> *names = @[@"Welcome", @"Account", @"Account setup", @"Plan & Payment", @"Recorder", @"Cameras", @"Local AI", @"Ready"];
1155
+ if (self.authorizationOnly) { names = @[@"Connected computer", @"Sign in", @"Ready"]; active = [self.lastStage isEqual:@"ready"] ? 2 : 1; }
1151
1156
  for (NSInteger index = 0; index < (NSInteger)self.stepLabels.count; index++) {
1152
1157
  NSTextField *field = self.stepLabels[(NSUInteger)index];
1158
+ field.hidden = index >= (NSInteger)names.count;
1159
+ if (field.hidden) continue;
1153
1160
  NSString *prefix = index < active ? @"OK" : [NSString stringWithFormat:@"%ld", index + 1];
1154
1161
  field.stringValue = [NSString stringWithFormat:@"%@ %@", prefix, names[(NSUInteger)index]];
1155
1162
  field.font = [NSFont systemFontOfSize:13 weight:index == active ? NSFontWeightSemibold : NSFontWeightRegular];
@@ -1293,6 +1300,32 @@ static int runGuidanceSmokeTest(void) {
1293
1300
  return 0;
1294
1301
  }
1295
1302
 
1303
+ static int runAuthorizationRailSmokeTest(void) {
1304
+ [NSApplication sharedApplication];
1305
+ TrillboardsSetupDelegate *delegate = [[TrillboardsSetupDelegate alloc] init];
1306
+ [delegate buildWindow];
1307
+ if (delegate.stepLabels.count != 8 || delegate.stepLabels.lastObject.hidden) return 1;
1308
+ [delegate renderState:@{@"stage": @"onboarding_account", @"authorizationOnly": @YES}];
1309
+ if (!delegate.signingIn || !delegate.authModeButton.hidden) return 2;
1310
+ NSArray<NSString *> *expected = @[@"Connected computer", @"Sign in", @"Ready"];
1311
+ for (NSUInteger index = 0; index < delegate.stepLabels.count; index++) {
1312
+ NSTextField *field = delegate.stepLabels[index];
1313
+ if (index < expected.count) {
1314
+ if (field.hidden || ![field.stringValue hasSuffix:expected[index]]) return 3;
1315
+ } else if (!field.hidden) return 4;
1316
+ }
1317
+ delegate.lastStage = @"ready";
1318
+ [delegate updateSteps:7];
1319
+ if (![delegate.stepLabels[1].stringValue hasPrefix:@"OK"] ||
1320
+ ![delegate.stepLabels[2].stringValue isEqual:@"3 Ready"]) return 5;
1321
+ [delegate renderState:@{@"stage": @"onboarding_account", @"authorizationOnly": @NO}];
1322
+ if (delegate.stepLabels.lastObject.hidden || delegate.authModeButton.hidden ||
1323
+ ![delegate.stepLabels[4].stringValue hasSuffix:@"Recorder"]) return 6;
1324
+ [delegate.window close];
1325
+ fprintf(stdout, "Native authorization sign-in, three-step rail, completion and onboarding restoration passed.\n");
1326
+ return 0;
1327
+ }
1328
+
1296
1329
  static int runCancellationSmokeTest(void) {
1297
1330
  NSString *pidPath = [NSTemporaryDirectory()
1298
1331
  stringByAppendingPathComponent:[NSString stringWithFormat:@"trillboards-setup-child-%@.pid", NSUUID.UUID.UUIDString]];
@@ -1416,6 +1449,9 @@ int main(int argc, const char *argv[]) {
1416
1449
  if (argc == 2 && [[NSString stringWithUTF8String:argv[1]] isEqualToString:@"--smoke-test-guidance"]) {
1417
1450
  return runGuidanceSmokeTest();
1418
1451
  }
1452
+ if (argc == 2 && [[NSString stringWithUTF8String:argv[1]] isEqualToString:@"--smoke-test-authorization-rail"]) {
1453
+ return runAuthorizationRailSmokeTest();
1454
+ }
1419
1455
  if (argc == 2 && [[NSString stringWithUTF8String:argv[1]] isEqualToString:@"--smoke-test-cancel"]) {
1420
1456
  return runCancellationSmokeTest();
1421
1457
  }
@@ -308,6 +308,19 @@ if pmset -g batt 2>/dev/null | grep -q "Battery Power"; then
308
308
  if is_ui; then plog "power: running on battery"; elif is_headless; then echo "[trillboards-pair] $BATT_NOTE"; else dialog_info "$BATT_NOTE"; fi
309
309
  fi
310
310
 
311
+ # An existing-PC sign-in authorizes control only; it never reboots sensing or reruns pairing.
312
+ if is_ui && [ -f "$CONFIG" ]; then
313
+ set +e
314
+ "$LAUNCHER" installer-onboarding --authorize-existing-if-requested --config "$CONFIG" --status-file "$UI_STATUS_FILE" "${NATIVE_UI_ARGS[@]}"
315
+ AUTH_RC=$?
316
+ set -e
317
+ case "$AUTH_RC" in
318
+ 0) exit 0 ;;
319
+ 10) : ;; # No pending request: retain normal resume/setup.
320
+ *) exit "$AUTH_RC" ;;
321
+ esac
322
+ fi
323
+
311
324
  # ─── Resume path: a saved, complete pairing skips the code prompt ─────────────
312
325
  # Branch on WHY verification failed: only an auth rejection (3) or a token-less
313
326
  # config (4) needs a new code — a network/server failure (2/5) means the saved
@@ -61,6 +61,23 @@ serves every Windows 10/11 — no per-arch builds.
61
61
  standard user, who is never prompted because they could not satisfy it — keeps
62
62
  a working task that repeats every 5 minutes but still needs someone logged on.
63
63
 
64
+ ## Release installation qualification
65
+
66
+ The existing Windows release job installs the complete signed candidate in a
67
+ fresh GitHub-hosted Windows profile before publishing. It requires successful
68
+ setup, the expected installed version, image inference, hidden supervised model
69
+ and detector tasks, repeat installation, both service restarts and supported
70
+ uninstall. The wrapper launch proof remains separate. JSON and logs are retained
71
+ without uploading the installer or model again.
72
+
73
+ To verify the public download afterward, dispatch release-connector-windows.yml
74
+ with dry_run=true and verify_published_release set to the exact live version.
75
+ That mode uses the existing real-model E2E job and skips build/publication. The
76
+ same full-install harness validates the public manifest, package hash and both
77
+ trusted signatures before installation. It refuses laptop, client-PC and
78
+ non-hosted-runner execution. Headless CI does not establish visible desktop
79
+ behavior, physical reboot, account pairing or the site's actual camera network.
80
+
64
81
  ## Build (CI: `release-connector-windows.yml`, runs on `windows-latest`)
65
82
 
66
83
  ```powershell
@@ -0,0 +1,213 @@
1
+ <# CI-only controlled investigation, never an installer qualification. #>
2
+ [CmdletBinding()]
3
+ param([Parameter(Mandatory=$true)][string]$PersonFrame)
4
+ $ErrorActionPreference='Stop'
5
+ Set-StrictMode -Version Latest
6
+ if($env:GITHUB_ACTIONS -ne 'true' -or $env:RUNNER_ENVIRONMENT -ne 'github-hosted' -or $env:RUNNER_OS -ne 'Windows' -or $PSVersionTable.PSVersion.Major -lt 7){throw 'Diagnostic requires a fresh hosted Windows runner and PowerShell7'}
7
+ if(-not(Test-Path -LiteralPath $PersonFrame -PathType Leaf)){throw 'Missing committed person fixture'}
8
+ $deploy=Split-Path -Parent $PSScriptRoot
9
+ $modelId='gemma-4-E2B-it.litertlm'
10
+ $modelSha='ab7838cdfc8f77e54d8ca45eadceb20452d9f01e4bfade03e5dce27911b27e42'
11
+ $litertVersion='0.16.0'
12
+ foreach($name in @('TrillboardsEdge','TrillboardsLiteRtLm','TrillboardsDetector')){
13
+ $taskErrors=@();$task=Get-ScheduledTask -TaskName $name -TaskPath '\' -ErrorAction SilentlyContinue -ErrorVariable taskErrors
14
+ if($task -or @($taskErrors|Where-Object{$_.CategoryInfo.Category -ne 'ObjectNotFound'}).Count){throw 'Diagnostic requires an empty task baseline'}
15
+ }
16
+ foreach($path in @((Join-Path $env:USERPROFILE '.litert-lm'),(Join-Path $env:USERPROFILE '.local\bin\litert-lm.exe'))){if(Test-Path -LiteralPath $path){throw 'Diagnostic requires an empty runtime profile'}}
17
+ if(Get-NetTCPConnection -LocalPort 9379 -State Listen -ErrorAction SilentlyContinue){throw 'Diagnostic port is occupied'}
18
+ $tempPrefix=[IO.Path]::GetFullPath($env:RUNNER_TEMP).TrimEnd('\')+'\'
19
+ $root=[IO.Path]::GetFullPath((Join-Path $env:RUNNER_TEMP ('tb-ai-diagnostic-'+[Guid]::NewGuid().ToString('N'))))
20
+ if(-not $root.StartsWith($tempPrefix,[StringComparison]::OrdinalIgnoreCase) -or (Test-Path -LiteralPath $root)){throw 'Unverified diagnostic root'}
21
+ New-Item -ItemType Directory -Path $root|Out-Null
22
+ $receipt=[ordered]@{atUtc=[DateTimeOffset]::UtcNow.ToString('o');head=$env:GITHUB_SHA;installationQualified=$false;diagnosticCompleted=$false;arms=@();phase='bootstrap';probeTimeoutSeconds=90}
23
+ $started=Get-Date
24
+ $powershell=Join-Path $env:WINDIR 'System32\WindowsPowerShell\v1.0\powershell.exe'
25
+ $litertPath=Join-Path $env:USERPROFILE '.local\bin\litert-lm.exe'
26
+ $stage=Join-Path $root 'source-runtime'
27
+ New-Item -ItemType Directory -Path $stage|Out-Null
28
+ function Invoke-DiagnosticProcess {
29
+ param([string]$File,[string[]]$Arguments,[string]$LogName,[int]$TimeoutSeconds)
30
+ $start=[Diagnostics.ProcessStartInfo]::new($File)
31
+ $start.UseShellExecute=$false;$start.CreateNoWindow=$true;$start.WindowStyle='Hidden'
32
+ $start.RedirectStandardOutput=$true;$start.RedirectStandardError=$true
33
+ $null=$start.Environment.Remove('PSModulePath')
34
+ foreach($argument in $Arguments){$start.ArgumentList.Add($argument)}
35
+ $process=[Diagnostics.Process]::new();$process.StartInfo=$start
36
+ try{
37
+ if(-not $process.Start()){throw 'Diagnostic child did not start'}
38
+ $stdout=$process.StandardOutput.ReadToEndAsync();$stderr=$process.StandardError.ReadToEndAsync()
39
+ if(-not $process.WaitForExit($TimeoutSeconds*1000)){$process.Kill($true);$process.WaitForExit();throw ('Diagnostic command deadline: '+$LogName)}
40
+ $text=$stdout.GetAwaiter().GetResult()+[Environment]::NewLine+$stderr.GetAwaiter().GetResult()
41
+ [IO.File]::WriteAllText((Join-Path $root $LogName),$text,[Text.UTF8Encoding]::new($false))
42
+ if($process.ExitCode -ne 0){throw ('Diagnostic command failed: '+$LogName+' exit '+$process.ExitCode)}
43
+ return $text
44
+ }finally{$process.Dispose()}
45
+ }
46
+ function Wait-DiagnosticModel {
47
+ $deadline=[DateTimeOffset]::UtcNow.AddSeconds(60)
48
+ do{
49
+ try{$models=Invoke-RestMethod -Uri 'http://127.0.0.1:9379/v1/models' -TimeoutSec 3;if(@($models.data|Where-Object{$_.id -eq $modelId}).Count -eq 1){return}}catch{}
50
+ Start-Sleep -Seconds 2
51
+ }while([DateTimeOffset]::UtcNow -lt $deadline)
52
+ throw 'Diagnostic model control route did not answer'
53
+ }
54
+ function Stop-DiagnosticModel {
55
+ if(Get-ScheduledTask -TaskName 'TrillboardsLiteRtLm' -TaskPath '\' -ErrorAction SilentlyContinue){
56
+ $null=Invoke-DiagnosticProcess $powershell @('-NoProfile','-NonInteractive','-ExecutionPolicy','Bypass','-File',(Join-Path $stage 'stop-local-ai.ps1'),'-Service','Model') 'stop-model.log' 90
57
+ }
58
+ }
59
+ try{
60
+ $cpu=Get-CimInstance Win32_Processor|Select-Object Name,NumberOfCores,NumberOfLogicalProcessors
61
+ $receipt.hardware=@{cpu=@($cpu);memoryBytes=(Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory}
62
+ $manifest=Invoke-RestMethod -Uri 'https://screen.trillboards.com/connector/trillboards-connector-windows.version.json' -Headers @{'Cache-Control'='no-cache'} -TimeoutSec 30
63
+ if($manifest.downloadUrl -ne 'https://screen.trillboards.com/connector/SenseAnythingConnector.exe' -or $manifest.sha256 -notmatch '^[a-f0-9]{64}$' -or $manifest.sizeBytes -lt 2GB -or $manifest.sizeBytes -gt 4GB){throw 'Unexpected public model carrier'}
64
+ $outer=Join-Path $root 'customer-model-carrier.exe'
65
+ Invoke-WebRequest -Uri $manifest.downloadUrl -OutFile $outer -TimeoutSec 1200
66
+ if((Get-Item -LiteralPath $outer).Length -ne $manifest.sizeBytes -or (Get-FileHash -LiteralPath $outer -Algorithm SHA256).Hash -ine $manifest.sha256){throw 'Model carrier does not match its manifest'}
67
+ $signature=Get-AuthenticodeSignature -LiteralPath $outer
68
+ if($signature.Status -ne 'Valid' -or $signature.SignerCertificate.Subject -notmatch '(?:^|,\s*)CN=Aethercorp Inc(?:,|$)'){throw 'Untrusted model carrier'}
69
+ $receipt.modelCarrier=@{version=$manifest.connectorVersion;sha256=$manifest.sha256;signature='Valid'}
70
+ $payload=Join-Path $root 'model-payload'
71
+ $null=Invoke-DiagnosticProcess (Get-Command 7z.exe -ErrorAction Stop).Source @('x',$outer,('-o'+$payload),'-y',$modelId) 'extract-model.log' 300
72
+ Remove-Item -LiteralPath $outer -Force
73
+ $model=Join-Path $payload $modelId
74
+ if((Get-FileHash -LiteralPath $model -Algorithm SHA256).Hash -ine $modelSha){throw 'Unexpected extracted model bytes'}
75
+ $localBin=Join-Path $env:USERPROFILE '.local\bin'
76
+ $env:PATH=$localBin+';'+$env:PATH
77
+ if(-not(Get-Command uv.exe -ErrorAction SilentlyContinue)){
78
+ # The vendor script declares $receipt. Run it in a child process so it
79
+ # cannot replace this diagnostic's receipt or other caller variables.
80
+ $uvBootstrap=Join-Path $root 'install-uv.ps1'
81
+ Invoke-WebRequest -Uri 'https://astral.sh/uv/install.ps1' -OutFile $uvBootstrap -TimeoutSec 30
82
+ $null=Invoke-DiagnosticProcess $powershell @('-NoProfile','-NonInteractive','-ExecutionPolicy','Bypass','-File',$uvBootstrap) 'install-uv.log' 180
83
+ }
84
+ $uv=(Get-Command uv.exe -ErrorAction Stop).Source
85
+ $null=Invoke-DiagnosticProcess $uv @('tool','install','--python','3.12','--managed-python','--force',('litert-lm=='+$litertVersion)) 'install-runtime.log' 300
86
+ foreach($name in @('register-litertlm-task.ps1','stop-local-ai.ps1','trillboards-hidden-run.vbs')){Copy-Item -LiteralPath (Join-Path $deploy $name) -Destination (Join-Path $stage $name)}
87
+ Copy-Item -LiteralPath (Join-Path $deploy '..\litertlm\trillboards_litertlm_shim.py') -Destination (Join-Path $stage 'trillboards_litertlm_shim.py')
88
+ $setup=Join-Path $deploy 'setup-litertlm.ps1'
89
+ $tokens=$null;$errors=$null;$ast=[Management.Automation.Language.Parser]::ParseFile($setup,[ref]$tokens,[ref]$errors)
90
+ if($errors){throw 'Source setup did not parse'}
91
+ $definitions=@()
92
+ foreach($name in @('Invoke-LitertlmShimNative','Get-LitertlmShimPaths','Get-LitertlmShimFiles','Get-ShimBytesHash','Install-LitertlmShim','Get-LitertlmConfigPath','Write-LitertlmConfig','Test-LitertlmVision')){
93
+ $definition=$ast.Find({param($node)$node -is [Management.Automation.Language.FunctionDefinitionAst] -and $node.Name -eq $name},$true)
94
+ if(-not $definition){throw ('Missing source diagnostic boundary: '+$name)}
95
+ # Bound this PRIVATE diagnostic control; the shipped 180-second probe is unchanged.
96
+ $definitions+=$definition.Extent.Text.Replace('-TimeoutSec 180','-TimeoutSec 90')
97
+ }
98
+ $probeAssignment=@($ast.EndBlock.Statements|Where-Object{$_ -is [Management.Automation.Language.AssignmentStatementAst] -and $_.Left.Extent.Text -eq '$script:LitertlmProbeJpegB64'})
99
+ if($probeAssignment.Count -ne 1){throw 'Missing actual installer image fixture'}
100
+ $bootstrapHeader=@'
101
+ param([string]$Mode,[string]$UvPath,[string]$ModelPath,[string]$ExpectedSha)
102
+ $ErrorActionPreference='Stop'
103
+ $ModelId='gemma-4-E2B-it.litertlm';$Port='9379';$BundledModelSha256=$ExpectedSha
104
+ $LitertDir=Join-Path $env:USERPROFILE '.litert-lm'
105
+ $logDir=Join-Path $env:LOCALAPPDATA 'Trillboards\logs'
106
+ New-Item -ItemType Directory -Force -Path $logDir|Out-Null
107
+ $LogPath=Join-Path $logDir 'ci-runtime-bootstrap.log'
108
+ function Log([string]$Message){Write-Host $Message}
109
+ '@
110
+ $bootstrapBody=@'
111
+ if($Mode -eq 'Bootstrap'){
112
+ if(-not(Install-LitertlmShim -UvPath $UvPath)){throw 'Actual source adapter did not install'}
113
+ $ErrorActionPreference='Continue'
114
+ & (Join-Path $env:USERPROFILE '.local\bin\litert-lm.exe') import $ModelPath $ModelId *>> $LogPath
115
+ if($LASTEXITCODE -ne 0){throw 'Diagnostic model import failed'}
116
+ $ErrorActionPreference='Stop'
117
+ if((Get-FileHash -LiteralPath (Join-Path $LitertDir ('models\'+$ModelId+'\model.litertlm')) -Algorithm SHA256).Hash -ine $ExpectedSha){throw 'Imported model differs from source'}
118
+ if(-not(Write-LitertlmConfig -SpeculativeDecoding $false)){throw 'Diagnostic CPU config write failed'}
119
+ Get-LitertlmShimPaths $UvPath|ConvertTo-Json -Compress
120
+ }elseif($Mode -eq 'Probe'){
121
+ [pscustomobject]@{installerProbePassed=[bool](Test-LitertlmVision -InferenceModel $ModelId)}|ConvertTo-Json -Compress
122
+ }else{throw 'Unknown private bootstrap action'}
123
+ '@
124
+ $bootstrap=Join-Path $stage 'diagnostic-bootstrap.ps1'
125
+ [IO.File]::WriteAllText($bootstrap,(@($bootstrapHeader)+$definitions+@($probeAssignment[0].Extent.Text,$bootstrapBody)-join [Environment]::NewLine),[Text.UTF8Encoding]::new($false))
126
+ $bootstrapOutput=Invoke-DiagnosticProcess $powershell @('-NoProfile','-NonInteractive','-ExecutionPolicy','Bypass','-File',$bootstrap,'-Mode','Bootstrap','-UvPath',$uv,'-ModelPath',$model,'-ExpectedSha',$modelSha) 'bootstrap.log' 600
127
+ $paths=(($bootstrapOutput -split '\r?\n'|Where-Object{$_.StartsWith('{"Source":') -or $_.StartsWith('{"Python":')}|Select-Object -Last 1)|ConvertFrom-Json)
128
+ if(-not $paths.Site -or -not(Test-Path -LiteralPath $paths.Site -PathType Container)){throw 'Diagnostic could not resolve installed runtime site'}
129
+ $receipt.phase='controlled-inference'
130
+ $captureInstalled=$false;$caseNumber=0
131
+ foreach($capture in @($false,$true,$false)){
132
+ $caseNumber++;$label=([string]$caseNumber)+'-'+$capture
133
+ Stop-DiagnosticModel
134
+ if(-not $capture -and $captureInstalled){
135
+ # Remove only the two files this diagnostic introduced in its CI venv.
136
+ Remove-Item -LiteralPath (Join-Path $paths.Site '00_trillboards_ci_service_capture.pth') -Force
137
+ Remove-Item -LiteralPath (Join-Path $paths.Site 'trillboards_ci_service_capture.py') -Force
138
+ $captureInstalled=$false
139
+ }
140
+ if($capture){
141
+ # Instrumentation lives ONLY in this disposable CI venv. The installed
142
+ # task action, S4U principal and source adapter remain identical.
143
+ $logger=@'
144
+ import os, sys
145
+ if sys.platform == "win32" and "serve" in sys.argv[1:]:
146
+ import ctypes, msvcrt, faulthandler
147
+ from pathlib import Path
148
+ _directory = Path(os.environ["LOCALAPPDATA"]) / "Trillboards" / "logs"
149
+ _directory.mkdir(parents=True, exist_ok=True)
150
+ _log = open(_directory / "litertlm-ci-service.log", "ab", buffering=0)
151
+ os.dup2(_log.fileno(), 1)
152
+ os.dup2(_log.fileno(), 2)
153
+ _kernel = ctypes.WinDLL("kernel32", use_last_error=True)
154
+ _kernel.SetStdHandle.argtypes = [ctypes.c_uint32, ctypes.c_void_p]
155
+ _kernel.SetStdHandle.restype = ctypes.c_int
156
+ for _fd, _identifier in ((1, -11), (2, -12)):
157
+ if not _kernel.SetStdHandle(ctypes.c_uint32(_identifier), ctypes.c_void_p(msvcrt.get_osfhandle(_fd))):
158
+ raise ctypes.WinError(ctypes.get_last_error())
159
+ # Retain the old objects so replacing a stream cannot close its remapped fd.
160
+ _prior_streams = (sys.stdout, sys.stderr)
161
+ sys.stdout = open(1, "w", buffering=1, encoding="utf-8", errors="backslashreplace", closefd=False)
162
+ sys.stderr = open(2, "w", buffering=1, encoding="utf-8", errors="backslashreplace", closefd=False)
163
+ faulthandler.enable(file=_log, all_threads=True)
164
+ faulthandler.dump_traceback_later(45, repeat=True, file=_log)
165
+ print("[CI diagnostic] redirected Win32 and CRT stdout/stderr; argv=" + repr(sys.argv), file=sys.stderr, flush=True)
166
+ '@
167
+ foreach($name in @('trillboards_ci_service_capture.py','00_trillboards_ci_service_capture.pth')){
168
+ if(Test-Path -LiteralPath (Join-Path $paths.Site $name)){throw 'Preserve an unexpected pre-existing diagnostic addon'}
169
+ }
170
+ [IO.File]::WriteAllText((Join-Path $paths.Site 'trillboards_ci_service_capture.py'),$logger,[Text.UTF8Encoding]::new($false))
171
+ [IO.File]::WriteAllText((Join-Path $paths.Site '00_trillboards_ci_service_capture.pth'),('import trillboards_ci_service_capture'+[Environment]::NewLine),[Text.UTF8Encoding]::new($false))
172
+ }
173
+ if($capture){$captureInstalled=$true}
174
+ $arm=[ordered]@{label=$label;capturedStdio=$capture;installerProbePassed=$false;personProbePassed=$false}
175
+ try{
176
+ $null=Invoke-DiagnosticProcess $powershell @('-NoProfile','-NonInteractive','-ExecutionPolicy','Bypass','-File',(Join-Path $stage 'register-litertlm-task.ps1'),'-LitertLmPath',$litertPath,'-Port','9379') ('register-'+$label+'.log') 90
177
+ Wait-DiagnosticModel
178
+ $task=Get-ScheduledTask -TaskName 'TrillboardsLiteRtLm' -TaskPath '\' -ErrorAction Stop
179
+ $arm.task=@{principal=[string]$task.Principal.LogonType;state=[string]$task.State;execute=[string]$task.Actions[0].Execute;arguments=[string]$task.Actions[0].Arguments}
180
+ try{
181
+ $probe=Invoke-DiagnosticProcess $powershell @('-NoProfile','-NonInteractive','-ExecutionPolicy','Bypass','-File',$bootstrap,'-Mode','Probe','-UvPath',$uv,'-ExpectedSha',$modelSha) ('installer-probe-'+$label+'.log') 120
182
+ $probeResult=(($probe -split '\r?\n'|Where-Object{$_.StartsWith('{"installerProbePassed":')}|Select-Object -Last 1)|ConvertFrom-Json)
183
+ $arm.installerProbePassed=$probeResult.installerProbePassed
184
+ }catch{$arm.installerProbeError=$_.Exception.Message}
185
+ try{
186
+ $image=[Convert]::ToBase64String([IO.File]::ReadAllBytes($PersonFrame))
187
+ $body=@{model=$modelId;max_completion_tokens=256;temperature=0;messages=@(@{role='user';content=@(@{type='text';text='Is a person visible? Answer YES or NO.'},@{type='image_url';image_url=@{url=('data:image/jpeg;base64,'+$image)}})})}|ConvertTo-Json -Depth 10
188
+ $answer=Invoke-RestMethod -Uri 'http://127.0.0.1:9379/v1/chat/completions' -Method Post -ContentType 'application/json' -Headers @{'X-Trillboards-Model-Sha256'=$modelSha} -Body $body -TimeoutSec 90
189
+ $arm.personInferenceAnswered=$true
190
+ $arm.personProbePassed=([string]$answer.choices[0].message.content -match '(?i)\byes\b' -and $answer.runtimeModel.sha256 -eq $modelSha)
191
+ $answer|ConvertTo-Json -Depth 8|Set-Content -LiteralPath (Join-Path $root ('person-response-'+$label+'.json'))
192
+ }catch{$arm.personProbeError=$_.Exception.Message}
193
+ }catch{$arm.error=$_.Exception.Message}
194
+ finally{
195
+ $arm.processes=@(Get-CimInstance Win32_Process -Filter "Name = 'python.exe'"|Select-Object ProcessId,ParentProcessId,WorkingSetSize,PrivatePageCount,CommandLine)
196
+ try{$arm.taskInfo=Get-ScheduledTaskInfo -TaskName 'TrillboardsLiteRtLm' -TaskPath '\'|Select-Object LastRunTime,LastTaskResult,NumberOfMissedRuns}catch{}
197
+ try{Stop-DiagnosticModel}catch{$arm.stopError=$_.Exception.Message}
198
+ $receipt.arms+=@([pscustomobject]$arm)
199
+ }
200
+ }
201
+ $receipt.diagnosticCompleted=$true;$receipt.phase='complete'
202
+ }catch{$receipt.failure=$_.Exception.Message;throw}
203
+ finally{
204
+ try{Stop-DiagnosticModel}catch{$receipt.cleanupFailure=$_.Exception.Message}
205
+ try{Get-WinEvent -FilterHashtable @{LogName='Application';StartTime=$started} -MaxEvents 100 -ErrorAction Stop|Where-Object{$_.ProviderName -match 'Application Error|Windows Error Reporting'}|Select-Object TimeCreated,ProviderName,Id,Message|ConvertTo-Json -Depth 5|Set-Content -LiteralPath (Join-Path $root 'application-events.json')}catch{}
206
+ try{$logs=Join-Path $env:LOCALAPPDATA 'Trillboards\logs';if(Test-Path -LiteralPath $logs){Copy-Item -LiteralPath $logs -Destination (Join-Path $root 'product-logs') -Recurse -Force}}catch{$receipt.logCopyFailure=$_.Exception.Message}
207
+ $receipt.completedAtUtc=[DateTimeOffset]::UtcNow.ToString('o')
208
+ $receipt|ConvertTo-Json -Depth 12|Set-Content -LiteralPath (Join-Path $root 'diagnostic.json')
209
+ if($env:GITHUB_OUTPUT){('artifact_path='+$root)|Out-File -LiteralPath $env:GITHUB_OUTPUT -Encoding utf8 -Append}
210
+ $receipt|ConvertTo-Json -Depth 12
211
+ }
212
+ # A controlled runtime diagnosis never clears the product installer gate.
213
+ if(@($receipt.arms|Where-Object{-not $_.installerProbePassed -or -not $_.personProbePassed}).Count){exit 1}
@@ -0,0 +1,243 @@
1
+ <#
2
+ Real customer-package qualification before publication and in the public-download E2E. Execute only on a fresh
3
+ GitHub-hosted Windows runner. This deliberately installs real local AI.
4
+ The parent uses PowerShell 7; the customer installer runs its shipped PS5.1
5
+ setup scripts. Do not run on the owner's laptop or the Dallas client PC.
6
+ #>
7
+ [CmdletBinding()]
8
+ param(
9
+ [Parameter(Mandatory = $true)][ValidatePattern('^0\.2\.[0-9]+$')][string]$ExpectedVersion,
10
+ [Parameter(Mandatory = $true)][string]$PersonFrame,
11
+ [string]$CustomerPackagePath = '',
12
+ [string]$ManifestPath = '',
13
+ [ValidateSet('Native','Inherited')][string]$PowerShellModuleEnvironment = 'Native'
14
+ )
15
+ $ErrorActionPreference = 'Stop'
16
+ Set-StrictMode -Version Latest
17
+ if ($env:GITHUB_ACTIONS -ne 'true' -or $env:RUNNER_OS -ne 'Windows' -or
18
+ $env:RUNNER_ENVIRONMENT -ne 'github-hosted' -or $PSVersionTable.PSVersion.Major -lt 7) {
19
+ throw 'Real installation qualification requires a fresh GitHub-hosted Windows runner and PowerShell 7'
20
+ }
21
+ if (-not (Test-Path -LiteralPath $PersonFrame -PathType Leaf)) { throw 'Missing committed person-image fixture' }
22
+ if ($env:TRILLBOARDS_BUNDLE_RELEASE_SMOKE_MARKER) { throw 'The no-install smoke marker must be absent' }
23
+ $taskNames = @('TrillboardsEdge', 'TrillboardsLiteRtLm', 'TrillboardsDetector')
24
+ foreach ($name in $taskNames) {
25
+ $taskErrors = @()
26
+ $task = Get-ScheduledTask -TaskName $name -TaskPath '\' -ErrorAction SilentlyContinue -ErrorVariable taskErrors
27
+ if ($task -or @($taskErrors | Where-Object { $_.CategoryInfo.Category -ne 'ObjectNotFound' }).Count) {
28
+ throw ('Cannot establish an empty scheduled-task baseline: ' + $name)
29
+ }
30
+ }
31
+ foreach ($path in @((Join-Path $env:LOCALAPPDATA 'Trillboards\edge'), (Join-Path $env:USERPROFILE '.litert-lm'),
32
+ (Join-Path $env:USERPROFILE '.local\bin\litert-lm.exe'), (Join-Path $env:USERPROFILE '.local\bin\trillboards-detector.exe'))) {
33
+ if (Test-Path -LiteralPath $path) { throw ('The CI profile already contains connector state: ' + $path) }
34
+ }
35
+ foreach ($port in @(9379, 9380)) {
36
+ if (Get-NetTCPConnection -LocalPort $port -State Listen -ErrorAction SilentlyContinue) {
37
+ throw ('The CI machine already has a listener on the local AI port: ' + $port)
38
+ }
39
+ }
40
+ $tempRoot = [IO.Path]::GetFullPath($env:RUNNER_TEMP).TrimEnd('\') + '\'
41
+ $root = [IO.Path]::GetFullPath((Join-Path $env:RUNNER_TEMP ('tb-published-install-' + [Guid]::NewGuid().ToString('N'))))
42
+ if (-not $root.StartsWith($tempRoot, [StringComparison]::OrdinalIgnoreCase) -or (Test-Path -LiteralPath $root)) {
43
+ throw 'Qualification needs a new, verified runner-temp child'
44
+ }
45
+ New-Item -ItemType Directory -Path $root | Out-Null
46
+ $installDir = Join-Path $root 'installed'
47
+ $receipt = [ordered]@{ atUtc = [DateTimeOffset]::UtcNow.ToString('o'); expectedVersion = $ExpectedVersion;
48
+ githubRunId = $env:GITHUB_RUN_ID; passed = $false; phase = 'manifest'; freshProfile = $true;
49
+ fullInstallerExecuted = $false; desktopVisibilityObserved = $false; rebootTested = $false;
50
+ installerModuleEnvironment = $PowerShellModuleEnvironment }
51
+
52
+ function Invoke-QualificationProcess {
53
+ param([string]$File, [string[]]$Arguments = @(), [string]$RawArguments = '', [string]$LogName, [int]$TimeoutSeconds, [switch]$InheritPowerShellModulePath)
54
+ $start = [Diagnostics.ProcessStartInfo]::new($File)
55
+ $start.UseShellExecute = $false; $start.CreateNoWindow = $true; $start.WindowStyle = 'Hidden'
56
+ $start.RedirectStandardOutput = $true; $start.RedirectStandardError = $true
57
+ # Native probes start like Explorer; the candidate gate deliberately keeps
58
+ # the Core path for installer/uninstaller launches to exercise their reset.
59
+ if (-not $InheritPowerShellModulePath) { $null = $start.Environment.Remove('PSModulePath') }
60
+ if ($RawArguments) { $start.Arguments = $RawArguments } else { foreach ($argument in $Arguments) { $start.ArgumentList.Add($argument) } }
61
+ $process = [Diagnostics.Process]::new(); $process.StartInfo = $start
62
+ $watch = [Diagnostics.Stopwatch]::StartNew()
63
+ try {
64
+ if (-not $process.Start()) { throw ('Could not start ' + $LogName) }
65
+ $stdout = $process.StandardOutput.ReadToEndAsync(); $stderr = $process.StandardError.ReadToEndAsync()
66
+ $timedOut = $false
67
+ while (-not $process.WaitForExit(20000)) {
68
+ Write-Host ('Running ' + $LogName + ': ' + [int]$watch.Elapsed.TotalSeconds + ' seconds')
69
+ if ($watch.Elapsed.TotalSeconds -ge $TimeoutSeconds) {
70
+ $process.Kill($true); $process.WaitForExit()
71
+ $timedOut = $true
72
+ break
73
+ }
74
+ }
75
+ $output = $stdout.GetAwaiter().GetResult() + "`n" + $stderr.GetAwaiter().GetResult()
76
+ [IO.File]::WriteAllText((Join-Path $root $LogName), $output, [Text.UTF8Encoding]::new($false))
77
+ if ($timedOut) { throw ('Owned CI command exceeded its deadline: ' + $LogName) }
78
+ if ($process.ExitCode -ne 0) { throw ($LogName + ' failed with exit ' + $process.ExitCode) }
79
+ return $output
80
+ } finally { $process.Dispose() }
81
+ }
82
+ function Invoke-InstalledUninstaller {
83
+ param([string]$InstallDir, [string]$RunRoot, [switch]$InheritPowerShellModulePath)
84
+ $installedUninstaller = Join-Path $InstallDir 'uninstall.exe'
85
+ $uninstaller = [IO.Path]::GetFullPath((Join-Path $RunRoot 'qualify-uninstall.exe'))
86
+ $installPrefix = [IO.Path]::GetFullPath($InstallDir).TrimEnd('\') + '\'
87
+ if ($uninstaller.StartsWith($installPrefix, [StringComparison]::OrdinalIgnoreCase)) {
88
+ throw 'Synchronous uninstall qualification must execute outside the installation directory'
89
+ }
90
+ # _?= suppresses NSIS's normal temporary copy so we can wait for the real
91
+ # exit status. Make that same copy ourselves: stop-existing owns executables
92
+ # under InstallDir and would otherwise terminate this in-place uninstaller.
93
+ Copy-Item -LiteralPath $installedUninstaller -Destination $uninstaller -ErrorAction Stop
94
+ $expectedHash = (Get-FileHash -LiteralPath $installedUninstaller -Algorithm SHA256).Hash
95
+ if ((Get-FileHash -LiteralPath $uninstaller -Algorithm SHA256).Hash -ine $expectedHash) {
96
+ throw 'The copied uninstaller differs from the installed customer uninstaller'
97
+ }
98
+ $null = Invoke-QualificationProcess -File $uninstaller -RawArguments ('/S _?=' + $InstallDir) -InheritPowerShellModulePath:$InheritPowerShellModulePath -LogName 'uninstall.log' -TimeoutSeconds 180
99
+ return $expectedHash.ToLowerInvariant()
100
+ }
101
+ function Assert-Publisher([string]$Path) {
102
+ $signature = Get-AuthenticodeSignature -LiteralPath $Path
103
+ if ($signature.Status -ne 'Valid' -or $signature.SignerCertificate.Subject -notmatch '(?:^|,\s*)CN=Aethercorp Inc(?:,|$)') {
104
+ throw ('The customer artifact lacks the trusted Aethercorp signature: ' + (Split-Path $Path -Leaf))
105
+ }
106
+ }
107
+ function Assert-HiddenTask([string]$Name) {
108
+ $task = Get-ScheduledTask -TaskName $Name -TaskPath '\' -ErrorAction Stop
109
+ $taskUser = [string]$task.Principal.UserId
110
+ $sid = if ($taskUser -match '^S-1-') { $taskUser } else {
111
+ (New-Object Security.Principal.NTAccount($taskUser)).Translate([Security.Principal.SecurityIdentifier]).Value
112
+ }
113
+ $actions = @($task.Actions)
114
+ $hostPath = Join-Path $installDir 'bin\trillboards-hidden-run.vbs'
115
+ $prefix = '//B //NoLogo "' + $hostPath + '" --wait "'
116
+ if ($sid -ne [Security.Principal.WindowsIdentity]::GetCurrent().User.Value -or -not $task.Settings.Enabled -or $task.State -ne 'Running' -or
117
+ $actions.Count -ne 1 -or [IO.Path]::GetFullPath($actions[0].Execute) -ine (Join-Path $env:WINDIR 'System32\wscript.exe') -or
118
+ -not ([string]$actions[0].Arguments).StartsWith($prefix, [StringComparison]::OrdinalIgnoreCase)) {
119
+ throw ('The installed local AI task does not use the owned waiting hidden host: ' + $Name)
120
+ }
121
+ }
122
+ function Wait-ModelReady {
123
+ $watch = [Diagnostics.Stopwatch]::StartNew()
124
+ do {
125
+ try {
126
+ $models = Invoke-RestMethod -Uri 'http://127.0.0.1:9379/v1/models' -TimeoutSec 5
127
+ if (@($models.data | Where-Object { $_.id -eq 'gemma-4-E2B-it.litertlm' }).Count -eq 1) { return }
128
+ } catch { }
129
+ Start-Sleep -Seconds 2
130
+ } while ($watch.Elapsed.TotalSeconds -lt 120)
131
+ throw 'The installed model endpoint did not become ready'
132
+ }
133
+ function Wait-DetectorAnswer {
134
+ $watch = [Diagnostics.Stopwatch]::StartNew()
135
+ do {
136
+ try {
137
+ $response = Invoke-WebRequest -Uri 'http://127.0.0.1:9380/health' -SkipHttpErrorCheck -TimeoutSec 5
138
+ if ([int]$response.StatusCode -in @(200,503)) { return }
139
+ } catch { }
140
+ Start-Sleep -Seconds 2
141
+ } while ($watch.Elapsed.TotalSeconds -lt 60)
142
+ throw 'The installed detector did not answer after restart'
143
+ }
144
+ function Assert-ImageInference {
145
+ $image = [Convert]::ToBase64String([IO.File]::ReadAllBytes($PersonFrame))
146
+ $body = @{ model = 'gemma-4-E2B-it.litertlm'; max_completion_tokens = 256; temperature = 0;
147
+ messages = @(@{ role = 'user'; content = @(@{ type = 'text'; text = 'Look at the image. Is there a person visible? Answer YES or NO.' },
148
+ @{ type = 'image_url'; image_url = @{ url = ('data:image/jpeg;base64,' + $image) } }) }) } | ConvertTo-Json -Depth 10
149
+ $answer = Invoke-RestMethod -Uri 'http://127.0.0.1:9379/v1/chat/completions' -Method Post -ContentType 'application/json' -Body $body -TimeoutSec 240
150
+ if (@($answer.choices).Count -lt 1 -or [string]$answer.choices[0].message.content -notmatch '(?i)\byes\b') {
151
+ throw 'The installed model did not confirm the person in the committed image fixture'
152
+ }
153
+ }
154
+ try {
155
+ if ([bool]$CustomerPackagePath -ne [bool]$ManifestPath) { throw 'Candidate package and manifest paths must be provided together' }
156
+ $localCandidate = [bool]$CustomerPackagePath
157
+ if ($localCandidate) {
158
+ $manifest = Get-Content -LiteralPath $ManifestPath -Raw | ConvertFrom-Json
159
+ $receipt.artifactSource = 'signed-build-candidate'
160
+ } else {
161
+ $manifest = Invoke-RestMethod -Uri 'https://screen.trillboards.com/connector/trillboards-connector-windows.version.json' -Headers @{ 'Cache-Control' = 'no-cache' } -TimeoutSec 30
162
+ $receipt.artifactSource = 'public-download'
163
+ }
164
+ if ($manifest.platform -ne 'windows-x64' -or $manifest.connectorVersion -ne $ExpectedVersion -or
165
+ $manifest.gitSha -notmatch '^[0-9a-f]{40}$' -or $manifest.sha256 -notmatch '^[0-9a-f]{64}$' -or
166
+ $manifest.sizeBytes -lt 2GB -or $manifest.sizeBytes -gt 4GB -or
167
+ $manifest.downloadUrl -ne 'https://screen.trillboards.com/connector/SenseAnythingConnector.exe') {
168
+ throw 'The live public manifest does not identify the expected complete customer package'
169
+ }
170
+ $manifest | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath (Join-Path $root 'public-manifest.json')
171
+ $receipt.artifactGitSha = $manifest.gitSha; $receipt.phase = 'download'
172
+ if ($localCandidate) {
173
+ $outer = (Resolve-Path -LiteralPath $CustomerPackagePath -ErrorAction Stop).ProviderPath
174
+ } else {
175
+ $outer = Join-Path $root 'SenseAnythingConnector.exe'
176
+ Invoke-WebRequest -Uri $manifest.downloadUrl -OutFile $outer -TimeoutSec 1200
177
+ }
178
+ if ((Get-Item -LiteralPath $outer).Length -ne $manifest.sizeBytes -or
179
+ (Get-FileHash -LiteralPath $outer -Algorithm SHA256).Hash -ine $manifest.sha256) { throw 'Customer package size/hash differs from the pinned manifest' }
180
+ Assert-Publisher $outer
181
+ $receipt.customerSha256 = $manifest.sha256; $receipt.phase = 'extract'
182
+ $payload = Join-Path $root 'customer-payload'
183
+ $sevenZip = (Get-Command 7z.exe -ErrorAction Stop).Source
184
+ $null = Invoke-QualificationProcess -File $sevenZip -Arguments @('x', $outer, ('-o' + $payload), '-y') -LogName 'extract.log' -TimeoutSeconds 300
185
+ $inner = Join-Path $payload 'TrillboardsEdgeSetup-core.exe'
186
+ $model = Join-Path $payload 'gemma-4-E2B-it.litertlm'
187
+ Assert-Publisher $inner
188
+ if (-not (Test-Path -LiteralPath $model -PathType Leaf)) { throw 'The published customer package did not contain its required model' }
189
+ # Keep receipts and logs as CI artifacts, never multi-gigabyte executables.
190
+ # Free the downloaded outer package before importing its extracted model.
191
+ if (-not $localCandidate) { Remove-Item -LiteralPath $outer -Force }
192
+ $installArgs = '/S /MODEL_SOURCE="' + $model + '" /D=' + $installDir
193
+ $receipt.phase = 'fresh-install'; $receipt.fullInstallerExecuted = $true
194
+ $null = Invoke-QualificationProcess -File $inner -RawArguments $installArgs -InheritPowerShellModulePath:($PowerShellModuleEnvironment -eq 'Inherited') -LogName 'fresh-install.log' -TimeoutSeconds 1200
195
+ $node = Join-Path $installDir 'bin\node.exe'; $cli = Join-Path $installDir 'lib\edge-sdk\dist\cli.js'
196
+ $version = Invoke-QualificationProcess -File $node -Arguments @($cli, 'version') -LogName 'installed-version.log' -TimeoutSeconds 30
197
+ if ($version -notmatch ('edge-sdk v' + [regex]::Escape($ExpectedVersion) + '(?:\s|$)')) { throw 'Installed connector version differs from the requested public release' }
198
+ Assert-HiddenTask 'TrillboardsLiteRtLm'; Assert-HiddenTask 'TrillboardsDetector'
199
+ $receipt.phase = 'fresh-install-readiness'
200
+ Wait-ModelReady; Wait-DetectorAnswer
201
+ $receipt.phase = 'fresh-install-inference'
202
+ Assert-ImageInference
203
+ $receipt.freshInstallPassed = $true; $receipt.phase = 'repeat-install'
204
+ $null = Invoke-QualificationProcess -File $inner -RawArguments $installArgs -InheritPowerShellModulePath:($PowerShellModuleEnvironment -eq 'Inherited') -LogName 'repeat-install.log' -TimeoutSeconds 900
205
+ Assert-HiddenTask 'TrillboardsLiteRtLm'; Assert-HiddenTask 'TrillboardsDetector'
206
+ $receipt.phase = 'repeat-install-readiness'
207
+ Wait-ModelReady; Wait-DetectorAnswer
208
+ $receipt.phase = 'repeat-install-inference'
209
+ Assert-ImageInference
210
+ $receipt.repeatInstallPassed = $true; $receipt.phase = 'service-restart'
211
+ $powershell = Join-Path $env:WINDIR 'System32\WindowsPowerShell\v1.0\powershell.exe'
212
+ foreach ($service in @(@{ Name = 'Model'; Task = 'TrillboardsLiteRtLm' }, @{ Name = 'Detector'; Task = 'TrillboardsDetector' })) {
213
+ $null = Invoke-QualificationProcess -File $powershell -Arguments @('-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-File',
214
+ (Join-Path $installDir 'bin\stop-local-ai.ps1'), '-Service', $service.Name) -LogName ('stop-' + $service.Name + '.log') -TimeoutSeconds 90
215
+ Enable-ScheduledTask -TaskName $service.Task -TaskPath '\' -ErrorAction Stop | Out-Null
216
+ Start-ScheduledTask -TaskName $service.Task -TaskPath '\' -ErrorAction Stop
217
+ Wait-ModelReady; Wait-DetectorAnswer
218
+ Assert-HiddenTask 'TrillboardsLiteRtLm'; Assert-HiddenTask 'TrillboardsDetector'
219
+ Assert-ImageInference
220
+ }
221
+ $receipt.serviceRestartPassed = $true; $receipt.phase = 'uninstall'
222
+ $receipt.uninstallerSha256 = Invoke-InstalledUninstaller -InstallDir $installDir -RunRoot $root -InheritPowerShellModulePath:($PowerShellModuleEnvironment -eq 'Inherited')
223
+ foreach ($name in $taskNames) {
224
+ if (Get-ScheduledTask -TaskName $name -TaskPath '\' -ErrorAction SilentlyContinue) { throw ('Uninstall left its scheduled task: ' + $name) }
225
+ }
226
+ foreach ($port in @(9379, 9380)) {
227
+ if (Get-NetTCPConnection -LocalPort $port -State Listen -ErrorAction SilentlyContinue) { throw ('Uninstall left its local AI listener: ' + $port) }
228
+ }
229
+ if (Test-Path -LiteralPath $cli -PathType Leaf) { throw 'Uninstall left the installed connector entry point' }
230
+ $receipt.uninstallPassed = $true; $receipt.phase = 'complete'; $receipt.passed = $true
231
+ } catch {
232
+ $receipt.failure = $_.Exception.Message
233
+ throw
234
+ } finally {
235
+ $logDir = Join-Path $env:LOCALAPPDATA 'Trillboards\logs'
236
+ try {
237
+ if (Test-Path -LiteralPath $logDir -PathType Container) { Copy-Item -LiteralPath $logDir -Destination (Join-Path $root 'product-logs') -Recurse -Force }
238
+ } catch { Write-Warning ('Some product logs could not be copied: ' + $_.Exception.Message) }
239
+ $receipt.completedAtUtc = [DateTimeOffset]::UtcNow.ToString('o')
240
+ $receipt | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath (Join-Path $root 'qualification.json')
241
+ if ($env:GITHUB_OUTPUT) { ('artifact_path=' + $root) | Out-File -LiteralPath $env:GITHUB_OUTPUT -Append -Encoding utf8 }
242
+ $receipt | ConvertTo-Json -Depth 8
243
+ }
@@ -276,18 +276,37 @@ if ($Mode -eq 'bench') {
276
276
  # NO real-model coverage on any lane until this ran. A regression that
277
277
  # breaks only the operator schema (an enum the model cannot satisfy, a
278
278
  # custom field the prompt never mentions) is invisible to the audience arm.
279
+ # setup already graded the delegates with a real image and retained its winner.
280
+ # Starting another failed GPU engine can block this serial service before the
281
+ # healthy CPU engine receives the schema request. Exercise the installed winner.
282
+ function Get-InstalledInferenceAccelerator([string]$ConfigPath) {
283
+ if (-not (Test-Path -LiteralPath $ConfigPath -PathType Leaf)) { return 'auto' }
284
+ $config = Get-Content -LiteralPath $ConfigPath -Raw -ErrorAction Stop | ConvertFrom-Json -ErrorAction Stop
285
+ $models = $config.PSObject.Properties['models']
286
+ if ($null -eq $models) { return 'auto' }
287
+ $model = $models.Value.PSObject.Properties['gemma-4-E2B-it.litertlm']
288
+ if ($null -eq $model) { return 'auto' }
289
+ $backend = $model.Value.PSObject.Properties['backend']
290
+ if ($null -ne $backend -and [string]$backend.Value -eq 'cpu') { return 'cpu' }
291
+ return 'auto'
292
+ }
293
+ $litertDirectory = if ([string]::IsNullOrWhiteSpace($env:LITERT_LM_DIR)) {
294
+ Join-Path $env:USERPROFILE '.litert-lm'
295
+ } else { $env:LITERT_LM_DIR }
296
+ $installedAccelerator = Get-InstalledInferenceAccelerator (Join-Path $litertDirectory 'config.json')
297
+ Log "schema smoke uses installer-verified delegate policy: $installedAccelerator"
279
298
  $verifyExit = 1
280
299
  try {
281
300
  $verify = Join-Path $PkgRoot 'scripts\verify-gemma4-vlm.mjs'
282
301
  $sopFields = Join-Path $PkgRoot 'scripts\fixtures\sop-profile-fields.json'
283
302
 
284
303
  Log "running real Gemma inference — AUDIENCE field set (--require-person)…"
285
- node $verify $Frame --litert "http://127.0.0.1:$Port" --require-person
304
+ node $verify $Frame --litert "http://127.0.0.1:$Port" --accelerator $installedAccelerator --require-person
286
305
  $verifyExit = $LASTEXITCODE
287
306
 
288
307
  if ($verifyExit -eq 0) {
289
308
  Log "running real Gemma inference — OPERATOR/SOP field set (--require-person)…"
290
- node $verify $Frame --litert "http://127.0.0.1:$Port" --require-person `
309
+ node $verify $Frame --litert "http://127.0.0.1:$Port" --accelerator $installedAccelerator --require-person `
291
310
  --field-set operator --profile-fields $sopFields
292
311
  $verifyExit = $LASTEXITCODE
293
312
  if ($verifyExit -ne 0) { Log "OPERATOR field set FAILED (exit $verifyExit)" }
@@ -295,6 +314,16 @@ try {
295
314
  } finally {
296
315
  if ($serveProc) { try { $serveProc.Kill() } catch {} }
297
316
  }
298
- if ($verifyExit -ne 0) { Die "real-model smoke FAILED (verify-gemma4-vlm.mjs exit $verifyExit)" }
317
+ if ($verifyExit -ne 0) {
318
+ Log '--- actual installed model service logs ---'
319
+ $productLogs = Join-Path $env:LOCALAPPDATA 'Trillboards\logs'
320
+ if (Test-Path -LiteralPath $productLogs) {
321
+ Get-ChildItem -LiteralPath $productLogs -Filter '*litert*' -File | ForEach-Object {
322
+ Log $_.Name
323
+ Get-Content -LiteralPath $_.FullName -Tail 60 -ErrorAction SilentlyContinue
324
+ }
325
+ }
326
+ Die "real-model smoke FAILED (verify-gemma4-vlm.mjs exit $verifyExit)"
327
+ }
299
328
  Pass "Windows on-device Gemma 4 E2B detected a person on the fixture (REAL inference, BOTH field sets)."
300
329
  exit 0