@trillboards/edge-sdk 0.2.220 → 0.2.222
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/macos/README.md +4 -2
- package/deploy/windows/README.md +12 -3
- package/deploy/windows/apply-update.ps1 +58 -0
- package/deploy/windows/ci/test-field-self-update.ps1 +35 -13
- package/deploy/windows/ci/test-published-install.ps1 +55 -7
- package/deploy/windows/ci/test-rollout-proofs.ps1 +538 -0
- package/deploy/windows/install-update.ps1 +147 -1
- package/dist/EdgeAgent.js +1 -1
- package/dist/SensingProfileClient.d.ts.map +1 -1
- package/dist/SensingProfileClient.js +5 -0
- package/dist/SensingProfileClient.js.map +1 -1
- package/dist/autoSense.d.ts.map +1 -1
- package/dist/autoSense.js +5 -0
- package/dist/autoSense.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +3 -1
- package/dist/cli.js.map +1 -1
- package/dist/connectorUpdate.d.ts +113 -28
- package/dist/connectorUpdate.d.ts.map +1 -1
- package/dist/connectorUpdate.js +289 -46
- package/dist/connectorUpdate.js.map +1 -1
- package/dist/connectorUpdateApply.d.ts +37 -0
- package/dist/connectorUpdateApply.d.ts.map +1 -1
- package/dist/connectorUpdateApply.js +70 -1
- package/dist/connectorUpdateApply.js.map +1 -1
- package/dist/diagnose.d.ts +1 -1
- package/dist/diagnose.js +1 -1
- package/package.json +1 -1
package/deploy/macos/README.md
CHANGED
|
@@ -105,8 +105,10 @@ the staged bundle** (`trillboards-edge version`) before packaging.
|
|
|
105
105
|
|
|
106
106
|
### Automatic updates
|
|
107
107
|
|
|
108
|
-
Every paired connector checks the macOS version manifest at launch
|
|
109
|
-
|
|
108
|
+
Every paired connector checks the macOS version manifest at launch, as soon as
|
|
109
|
+
the API's sensing-profile answer names a newer release, and hourly. A published
|
|
110
|
+
release is taken at once (no hold unless ops sets runtime_config
|
|
111
|
+
`CONNECTOR_UPDATE_MIN_RELEASE_AGE_MS`); the connector downloads the
|
|
110
112
|
content-addressed code-only package while sensing remains online. Before it can
|
|
111
113
|
be staged, macOS must validate the exact Aethercorp Developer ID Installer
|
|
112
114
|
identity, the notarization staple, Gatekeeper acceptance, size, and SHA-256.
|
package/deploy/windows/README.md
CHANGED
|
@@ -119,10 +119,19 @@ An installed connector keeps itself current. It is the only consumer of
|
|
|
119
119
|
`trillboards-connector-windows.version.json`, which until now was published,
|
|
120
120
|
correct, and read by nothing.
|
|
121
121
|
|
|
122
|
-
- **Check** — `src/connectorUpdate.ts` reads the manifest
|
|
123
|
-
|
|
122
|
+
- **Check** — `src/connectorUpdate.ts` reads the manifest at launch, the moment
|
|
123
|
+
the API's sensing-profile answer (polled by every RTSP feed every 5 min)
|
|
124
|
+
names a newer release in `connectorRelease`, and hourly as a backstop. There
|
|
125
|
+
is no release hold: a published release is taken at once unless ops sets
|
|
126
|
+
runtime_config `CONNECTOR_UPDATE_MIN_RELEASE_AGE_MS` (default 0). It posts the
|
|
124
127
|
running version plus the advertised one to
|
|
125
|
-
`POST /v2/earner/cameras/connector-status`.
|
|
128
|
+
`POST /v2/earner/cameras/connector-status`.
|
|
129
|
+
- **Health check + rollback** — `install-update.ps1` starts the new version and
|
|
130
|
+
waits for it to write `.auto-update\health.json` (startup completed, update
|
|
131
|
+
loop running) and stay up 20 s. A version that fails three starts (10 s
|
|
132
|
+
apart), or reports nothing in 5 min, is rolled back to `.previous` and listed in
|
|
133
|
+
`.auto-update\failed-versions.json`, which the restored connector never takes
|
|
134
|
+
again. Proven by `ci/test-rollout-proofs.ps1`. A MISSING manifest answers
|
|
126
135
|
`HTTP 200 text/html` on this CDN, so the client validates every field rather
|
|
127
136
|
than the status code, and an unreadable manifest reports UNKNOWN — never
|
|
128
137
|
"up to date".
|
|
@@ -156,6 +156,62 @@ function Start-ApplierLog {
|
|
|
156
156
|
} catch { }
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
<#
|
|
160
|
+
One update transaction at a time on this install.
|
|
161
|
+
|
|
162
|
+
A connector that a commit has just started checks for updates at once, and
|
|
163
|
+
the release doorbell can ring seconds later, both while the commit that
|
|
164
|
+
started it is still in install-update.ps1's health wait. A stage launched
|
|
165
|
+
then could not open the shared transcript, cleared the payload directory the
|
|
166
|
+
commit was running from, and had what it staged deleted again by the commit's
|
|
167
|
+
own cleanup a few seconds later, so the connector sat out the 60-minute stage
|
|
168
|
+
deadline for a release already on the CDN (rollout proof, run 42549096785: a
|
|
169
|
+
release published 2 s after an update landed was never staged).
|
|
170
|
+
|
|
171
|
+
So every applier first waits for any applier of this install that started
|
|
172
|
+
before it to exit, and touches nothing in .auto-update until then. It looks
|
|
173
|
+
at processes rather than at a lock because the commit it waits for can be an
|
|
174
|
+
earlier release's applier, which takes no lock. "Started before it" orders
|
|
175
|
+
any two appliers one way only, so two can never wait for each other.
|
|
176
|
+
#>
|
|
177
|
+
$ApplierWaitMinutes = 30
|
|
178
|
+
|
|
179
|
+
function Get-EarlierAppliers([string]$ScriptPath) {
|
|
180
|
+
$self = Get-CimInstance -ClassName Win32_Process -Filter "ProcessId = $PID" -ErrorAction Stop
|
|
181
|
+
@(Get-CimInstance -ClassName Win32_Process -Filter "Name = 'powershell.exe' OR Name = 'pwsh.exe'" -ErrorAction Stop |
|
|
182
|
+
Where-Object {
|
|
183
|
+
$_.ProcessId -ne $PID -and $_.CommandLine -and
|
|
184
|
+
$_.CommandLine.IndexOf($ScriptPath, [StringComparison]::OrdinalIgnoreCase) -ge 0 -and
|
|
185
|
+
($_.CreationDate -lt $self.CreationDate -or ($_.CreationDate -eq $self.CreationDate -and $_.ProcessId -lt $PID))
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function Wait-EarlierAppliers {
|
|
190
|
+
$script:applierWaitNote = $null
|
|
191
|
+
$scriptPath = Join-Path ($InstallDir.TrimEnd('\')) 'bin\apply-update.ps1'
|
|
192
|
+
$started = [DateTime]::UtcNow
|
|
193
|
+
$deadline = $started.AddMinutes($ApplierWaitMinutes)
|
|
194
|
+
$waitedFor = @{}
|
|
195
|
+
while ($true) {
|
|
196
|
+
try {
|
|
197
|
+
$earlier = @(Get-EarlierAppliers $scriptPath)
|
|
198
|
+
} catch {
|
|
199
|
+
$script:applierWaitNote = "could not list other update processes, so did not wait for any: $($_.Exception.Message)"
|
|
200
|
+
return
|
|
201
|
+
}
|
|
202
|
+
if ($earlier.Count -eq 0) { break }
|
|
203
|
+
foreach ($p in $earlier) { $waitedFor[[string]$p.ProcessId] = $true }
|
|
204
|
+
if ([DateTime]::UtcNow -ge $deadline) {
|
|
205
|
+
Start-ApplierLog
|
|
206
|
+
Fail 'rejected' ("another update of this install (pid {0}) was still running after {1} min" -f (@($earlier | ForEach-Object { $_.ProcessId }) -join ', '), $ApplierWaitMinutes)
|
|
207
|
+
}
|
|
208
|
+
Start-Sleep -Seconds 2
|
|
209
|
+
}
|
|
210
|
+
if ($waitedFor.Count -gt 0) {
|
|
211
|
+
$script:applierWaitNote = ("waited {0:N0} s for the earlier update process (pid {1}) to exit" -f ([DateTime]::UtcNow - $started).TotalSeconds, (@($waitedFor.Keys) -join ', '))
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
159
215
|
<#
|
|
160
216
|
-Detach: run this same phase OUTSIDE the caller's job object.
|
|
161
217
|
|
|
@@ -633,7 +689,9 @@ function Invoke-Commit {
|
|
|
633
689
|
# ---------------------------------------------------------------------------
|
|
634
690
|
if ($Stage -and $Commit) { Fail 'rejected' 'pass exactly one of -Stage or -Commit' }
|
|
635
691
|
if ($Detach) { Invoke-Detached; exit 0 }
|
|
692
|
+
Wait-EarlierAppliers
|
|
636
693
|
Start-ApplierLog
|
|
694
|
+
if ($script:applierWaitNote) { Log $script:applierWaitNote }
|
|
637
695
|
if ($Stage) { Invoke-Stage; exit 0 }
|
|
638
696
|
if ($Commit) { Invoke-Commit; exit 0 }
|
|
639
697
|
Fail 'rejected' 'pass -Stage or -Commit'
|
|
@@ -4,14 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
Installs a published connector from its immutable address, gives it a real
|
|
6
6
|
RTSP camera and a stub API, starts it under its own scheduled task exactly as
|
|
7
|
-
pairing does, and then waits for it to take the
|
|
8
|
-
help. PASS only when the installed tree, the task and the connector's
|
|
9
|
-
status report all name
|
|
7
|
+
pairing does, and then waits for it to take the newest release it will take
|
|
8
|
+
with no help. PASS only when the installed tree, the task and the connector's
|
|
9
|
+
own status report all name that version.
|
|
10
|
+
|
|
11
|
+
Which release that is depends on the installed build: one before
|
|
12
|
+
$NoReleaseHoldSince still holds every release six hours after it published,
|
|
13
|
+
so it takes the newest signed release at least six hours old; one from
|
|
14
|
+
$NoReleaseHoldSince on takes the newest signed release at once.
|
|
10
15
|
|
|
11
16
|
-InstallerUrl auto (the default) picks the newest published build that
|
|
12
17
|
carries the job-safe updater (>= $JobSafeUpdaterSince) and is older than the
|
|
13
|
-
|
|
14
|
-
they cannot pass this test; pass one explicitly to watch that happen.
|
|
18
|
+
newest release. Builds before it start their applier inside the task the swap
|
|
19
|
+
stops, so they cannot pass this test; pass one explicitly to watch that happen.
|
|
15
20
|
|
|
16
21
|
Why this exists. The release gate proves apply-update.ps1 in isolation
|
|
17
22
|
(verify-update-applier.ps1, arms A-K), but no CI step had ever let an
|
|
@@ -39,6 +44,8 @@ if (-not (Test-Path -LiteralPath $PersonFrame -PathType Leaf)) { throw 'Missing
|
|
|
39
44
|
# The first release whose applier leaves the connector task before the swap
|
|
40
45
|
# stops it (apply-update.ps1 -Detach).
|
|
41
46
|
$JobSafeUpdaterSince = [version]'0.2.190'
|
|
47
|
+
# The first release that takes a release at once instead of holding it six hours.
|
|
48
|
+
$NoReleaseHoldSince = [version]'0.2.221'
|
|
42
49
|
|
|
43
50
|
$installDir = Join-Path $env:LOCALAPPDATA 'Trillboards\edge'
|
|
44
51
|
if (Test-Path -LiteralPath $installDir) { throw 'The CI profile already holds a connector install' }
|
|
@@ -124,15 +131,14 @@ try {
|
|
|
124
131
|
|
|
125
132
|
$receipt.phase = 'root-manifest'
|
|
126
133
|
$rootManifest = Invoke-RestMethod -Uri 'https://screen.trillboards.com/connector/trillboards-connector-windows.version.json' -Headers @{ 'Cache-Control' = 'no-cache' } -TimeoutSec 30
|
|
127
|
-
$
|
|
128
|
-
$
|
|
134
|
+
$published = @($rootManifest)
|
|
135
|
+
if ($rootManifest.PSObject.Properties.Name -contains 'releaseHistory') { $published += @($rootManifest.releaseHistory) }
|
|
136
|
+
$newestVersion = [string](@($published | Sort-Object { [version]$_.connectorVersion } -Descending)[0].connectorVersion)
|
|
129
137
|
if ($InstallerUrl -eq 'auto') {
|
|
130
|
-
$
|
|
131
|
-
if ($rootManifest.PSObject.Properties.Name -contains 'releaseHistory') { $published += @($rootManifest.releaseHistory) }
|
|
132
|
-
$pick = @($published | Where-Object { [version]$_.connectorVersion -ge $JobSafeUpdaterSince -and [version]$_.connectorVersion -lt [version]$targetVersion } |
|
|
138
|
+
$pick = @($published | Where-Object { [version]$_.connectorVersion -ge $JobSafeUpdaterSince -and [version]$_.connectorVersion -lt [version]$newestVersion } |
|
|
133
139
|
Sort-Object { [version]$_.connectorVersion } -Descending) | Select-Object -First 1
|
|
134
140
|
if (-not $pick) {
|
|
135
|
-
Note ('SKIP: no published build with the job-safe updater (>= ' + $JobSafeUpdaterSince + ') is older than the
|
|
141
|
+
Note ('SKIP: no published build with the job-safe updater (>= ' + $JobSafeUpdaterSince + ') is older than the newest release ' + $newestVersion + ' yet')
|
|
136
142
|
$receipt.phase = 'skipped'; $receipt.passed = $true
|
|
137
143
|
return
|
|
138
144
|
}
|
|
@@ -144,8 +150,24 @@ try {
|
|
|
144
150
|
$fromVersion = $m.Groups[1].Value
|
|
145
151
|
$fromSha256 = $m.Groups[3].Value
|
|
146
152
|
$receipt.fromVersion = $fromVersion
|
|
147
|
-
|
|
148
|
-
|
|
153
|
+
# The release this build will take: the newest signed one newer than it, and
|
|
154
|
+
# for a build that still holds releases, only one published six hours ago.
|
|
155
|
+
$holdsReleases = [version]$fromVersion -lt $NoReleaseHoldSince
|
|
156
|
+
$nowUtc = [DateTime]::UtcNow
|
|
157
|
+
$eligible = @($published | Where-Object {
|
|
158
|
+
$_.PSObject.Properties.Name -contains 'updateUrl' -and $_.updateUrl -and
|
|
159
|
+
$_.PSObject.Properties.Name -contains 'updateCatalogUrl' -and $_.updateCatalogUrl -and
|
|
160
|
+
[version]$_.connectorVersion -gt [version]$fromVersion -and
|
|
161
|
+
(-not $holdsReleases -or ($nowUtc - $(if ($_.publishedAt -is [DateTime]) { $_.publishedAt.ToUniversalTime() } else { [DateTimeOffset]::Parse([string]$_.publishedAt).UtcDateTime })).TotalHours -ge 6) } |
|
|
162
|
+
Sort-Object { [version]$_.connectorVersion } -Descending)
|
|
163
|
+
if ($eligible.Count -eq 0) {
|
|
164
|
+
Note ('SKIP: ' + $fromVersion + ' would take no published release yet (holds releases six hours: ' + $holdsReleases + ')')
|
|
165
|
+
$receipt.phase = 'skipped'; $receipt.passed = $true
|
|
166
|
+
return
|
|
167
|
+
}
|
|
168
|
+
$targetVersion = [string]$eligible[0].connectorVersion
|
|
169
|
+
$receipt.targetVersion = $targetVersion
|
|
170
|
+
Note ('field build ' + $fromVersion + ' must update itself to ' + $targetVersion + ' (newest published ' + $newestVersion + ')')
|
|
149
171
|
|
|
150
172
|
$receipt.phase = 'download'
|
|
151
173
|
$outer = Join-Path $root 'SenseAnythingConnector.exe'
|
|
@@ -319,6 +319,43 @@ function Get-QualificationConnectorTaskState {
|
|
|
319
319
|
function Invoke-QualificationServiceInspection([string]$Service) {
|
|
320
320
|
& (Join-Path $installDir 'bin\stop-local-ai.ps1') -Service $Service -Inspect
|
|
321
321
|
}
|
|
322
|
+
<#
|
|
323
|
+
A process WMI listed a moment ago may be EXITING rather than changed. A
|
|
324
|
+
terminating process stays in Win32_Process briefly with its image path and
|
|
325
|
+
command line already torn down, and a PID can be reused once it has gone.
|
|
326
|
+
0.2.215's publication failed twice on exactly that shape, on short-lived children
|
|
327
|
+
(a console host; the connector's reg.exe/netsh.exe proxy probes): "Bootstrap
|
|
328
|
+
actor identity is unavailable" (run 42519120444 attempt 1: PID 7788, a conhost
|
|
329
|
+
listed with empty path and command line seconds after it had been verified)
|
|
330
|
+
and "Bootstrap actor changed during owner inspection" (attempt 2).
|
|
331
|
+
|
|
332
|
+
Re-reads one PID and says which it is:
|
|
333
|
+
gone no such PID now (the process listed has exited)
|
|
334
|
+
exiting the same process (same creation time) with its identity torn down:
|
|
335
|
+
still BUSY, so the drain waits for it, but nothing is verified
|
|
336
|
+
reused another process under the number: refused, as before
|
|
337
|
+
live the same process, readable (Process = the fresh record)
|
|
338
|
+
Only the first two are new: a reused PID, or a readable process whose image
|
|
339
|
+
or command line differs, is still refused by the callers.
|
|
340
|
+
#>
|
|
341
|
+
function Get-BootstrapProcessState([int]$Id, [string]$CreationDate) {
|
|
342
|
+
$live = @(Get-CimInstance -ClassName Win32_Process -Filter ('ProcessId=' + $Id) -OperationTimeoutSec 5 -ErrorAction Stop)
|
|
343
|
+
if ($live.Count -eq 0) { return [pscustomobject]@{ State = 'gone'; Process = $null } }
|
|
344
|
+
if ($live.Count -ne 1 -or ($CreationDate -and [string]$live[0].CreationDate -cne $CreationDate)) {
|
|
345
|
+
return [pscustomobject]@{ State = 'reused'; Process = $live[0] }
|
|
346
|
+
}
|
|
347
|
+
if (-not $live[0].ExecutablePath -or -not $live[0].CommandLine) { return [pscustomobject]@{ State = 'exiting'; Process = $live[0] } }
|
|
348
|
+
return [pscustomobject]@{ State = 'live'; Process = $live[0] }
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
# Still BUSY (the drain waits for it to go) but never verified or traced: an
|
|
352
|
+
# exiting process has nothing left to verify.
|
|
353
|
+
function New-ExitingBootstrapActor([int]$Id, $Process) {
|
|
354
|
+
return [pscustomobject]@{ ProcessId=$Id; ParentProcessId=[int]$Process.ParentProcessId;
|
|
355
|
+
CreationDate=[string]$Process.CreationDate; Exe=''; CommandLine=''; Sid=$null; OwnershipVerified=$false;
|
|
356
|
+
RoleVerified=$false; Exiting=$true }
|
|
357
|
+
}
|
|
358
|
+
|
|
322
359
|
function Get-QualificationBootstrapActors($Context) {
|
|
323
360
|
if ($null -eq $Context.AllowedHosts) {
|
|
324
361
|
$Context.AllowedHosts = @()
|
|
@@ -405,19 +442,30 @@ function Get-QualificationBootstrapActors($Context) {
|
|
|
405
442
|
CreationDate=[string]$process.CreationDate; Exe=[string]$process.ExecutablePath; CommandLine=[string]$process.CommandLine;
|
|
406
443
|
Sid=$null; OwnershipVerified=$false; RoleVerified=$false }
|
|
407
444
|
}
|
|
408
|
-
if (-not $process.CreationDate
|
|
445
|
+
if (-not $process.CreationDate) { throw 'Bootstrap actor identity is unavailable' }
|
|
446
|
+
if (-not $process.ExecutablePath -or -not $process.CommandLine) {
|
|
447
|
+
# A torn record is a process on its way out, or one already gone; re-read
|
|
448
|
+
# it rather than refusing the whole qualification.
|
|
449
|
+
$fresh = Get-BootstrapProcessState $id ([string]$process.CreationDate)
|
|
450
|
+
if ($fresh.State -eq 'gone') { continue }
|
|
451
|
+
if ($fresh.State -eq 'exiting') { $busy += (New-ExitingBootstrapActor $id $process); continue }
|
|
452
|
+
if ($fresh.State -ne 'live') { throw 'Bootstrap actor identity is unavailable' }
|
|
453
|
+
$process = $fresh.Process
|
|
454
|
+
}
|
|
409
455
|
$identity = [string]$process.CreationDate + '|' + [string]$process.ExecutablePath + '|' + [string]$process.CommandLine
|
|
410
456
|
if ($Context.Traced.ContainsKey($id) -and $Context.Traced[$id] -cne $identity) { throw 'A bootstrap PID was replaced during isolation' }
|
|
411
457
|
try { $owner = Invoke-CimMethod -InputObject $process -MethodName GetOwnerSid -OperationTimeoutSec 5 -ErrorAction Stop }
|
|
412
458
|
catch {
|
|
413
|
-
$
|
|
414
|
-
if ($
|
|
459
|
+
$after = Get-BootstrapProcessState $id ([string]$process.CreationDate)
|
|
460
|
+
if ($after.State -eq 'gone') { continue }
|
|
461
|
+
if ($after.State -eq 'exiting') { $busy += (New-ExitingBootstrapActor $id $process); continue }
|
|
415
462
|
throw
|
|
416
463
|
}
|
|
417
|
-
$
|
|
418
|
-
if ($
|
|
419
|
-
if ($
|
|
420
|
-
|
|
464
|
+
$after = Get-BootstrapProcessState $id ([string]$process.CreationDate)
|
|
465
|
+
if ($after.State -eq 'gone') { continue }
|
|
466
|
+
if ($after.State -eq 'exiting') { $busy += (New-ExitingBootstrapActor $id $process); continue }
|
|
467
|
+
if ($after.State -ne 'live' -or
|
|
468
|
+
([string]$after.Process.CreationDate + '|' + [string]$after.Process.ExecutablePath + '|' + [string]$after.Process.CommandLine) -cne $identity) {
|
|
421
469
|
throw 'Bootstrap actor changed during owner inspection'
|
|
422
470
|
}
|
|
423
471
|
if ($owner.ReturnValue -ne 0 -or $owner.Sid -ne $Context.Task.Sid) { throw 'A related bootstrap actor has foreign or unknown ownership' }
|