fix(orchestration): preserve active workers across updates (#11271)
* fix(orchestration): preserve active workers across updates * test(ssh): model absent legacy adoption * test(orchestration): align compatibility contracts * fix(windows): escape updater PowerShell booleans * fix(windows): restore stock uninstall process check * fix(orchestration): keep recovery off renderer startup barrier * fix(orchestration): harden legacy recovery migration * fix(orchestration): close recovery review gaps * fix(orchestration): complete legacy worker cutover recovery * fix(orchestration): preserve legacy workers across updates --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
committed by
Neil
co-authored by
OrcaWin
parent
3240c26bce
commit
959e8d63b0
@@ -54,6 +54,7 @@ Or directly: `node tools/win-update-e2e/run.mjs --from ... --to ... --expect ...
|
||||
| `--install-dir <path>` | Isolated-install mode (see below) — install into `<path>` |
|
||||
| `--asset-pattern <glob>` | gh asset glob (default `*windows-setup.exe`) |
|
||||
| `--soak-seconds <n>` | Post-relaunch window-watch soak (default `180`) |
|
||||
| `--require-distinct-artifacts` | Require distinct N/B paths, versions, and SHA-256 hashes |
|
||||
| `--keep-install` | Skip teardown/uninstall for debugging (ignored in isolated) |
|
||||
|
||||
### Profiles
|
||||
@@ -210,6 +211,14 @@ powershell -File tools/win-update-e2e/window-enum.ps1
|
||||
|
||||
## Known limitations
|
||||
|
||||
- **This is installer/session scaffolding, not the orchestration cutover gate.**
|
||||
`--require-distinct-artifacts` makes the existing Windows update journey fail
|
||||
closed unless it received two provably different packages. A CI follow-up
|
||||
must still drive the packaged updater with a blocked packaged `orca.exe` ask,
|
||||
prove launcher status `75` and the exact native/WSL resume command, then
|
||||
record one question and reply on B. That proof requires distinct installed
|
||||
A/B artifacts and a physical Windows host with WSL; this harness does not
|
||||
simulate either contract.
|
||||
- **Scrollback fidelity is best-effort.** A production build renders the
|
||||
terminal with WebGL, so xterm text is not reliably in the DOM and the e2e
|
||||
`SerializeAddon` is not exposed. When text cannot be read the check reports
|
||||
|
||||
@@ -52,6 +52,9 @@ Options:
|
||||
--keep-install Skip teardown/uninstall (leaves the app installed)
|
||||
--asset-pattern <glob> gh release asset glob (default: *windows-setup.exe)
|
||||
--soak-seconds <n> Post-relaunch window watch duration (default: 180)
|
||||
--require-distinct-artifacts
|
||||
Fail unless N and N+1 have distinct paths, versions,
|
||||
and SHA-256 hashes. Intended for compatibility gates.
|
||||
-h, --help Show this help
|
||||
`
|
||||
|
||||
@@ -71,6 +74,7 @@ export function parseArgs(argv) {
|
||||
installDir: takeValue(argv, '--install-dir'),
|
||||
keepInstall: argv.includes('--keep-install'),
|
||||
allowExistingInstall: argv.includes('--allow-existing-install'),
|
||||
requireDistinctArtifacts: argv.includes('--require-distinct-artifacts'),
|
||||
usage: USAGE
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import { createHash } from 'node:crypto'
|
||||
import { createReadStream } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
async function sha256(filePath) {
|
||||
const hash = createHash('sha256')
|
||||
for await (const chunk of createReadStream(filePath)) {
|
||||
hash.update(chunk)
|
||||
}
|
||||
return hash.digest('hex')
|
||||
}
|
||||
|
||||
export async function proveDistinctInstallerPair({ fromPath, toPath, fromVersion, toVersion }) {
|
||||
const [fromHash, toHash] = await Promise.all([sha256(fromPath), sha256(toPath)])
|
||||
const proof = {
|
||||
from: { path: path.resolve(fromPath), version: fromVersion, sha256: fromHash },
|
||||
to: { path: path.resolve(toPath), version: toVersion, sha256: toHash }
|
||||
}
|
||||
const errors = []
|
||||
if (proof.from.path.toLowerCase() === proof.to.path.toLowerCase()) {
|
||||
errors.push('base and candidate installer paths are identical')
|
||||
}
|
||||
if (fromHash === toHash) {
|
||||
errors.push('base and candidate installer SHA-256 hashes are identical')
|
||||
}
|
||||
if (!fromVersion || !toVersion) {
|
||||
errors.push('both installer versions must be readable')
|
||||
} else if (fromVersion === toVersion) {
|
||||
errors.push(`base and candidate installer versions are identical (${fromVersion})`)
|
||||
}
|
||||
if (errors.length > 0) {
|
||||
throw new Error(`Distinct installer proof failed: ${errors.join('; ')}`)
|
||||
}
|
||||
return proof
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
import { mkdtemp, rm, writeFile } from 'node:fs/promises'
|
||||
import os from 'node:os'
|
||||
import path from 'node:path'
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { parseArgs } from './cli-args.mjs'
|
||||
import { proveDistinctInstallerPair } from './installer-pair-proof.mjs'
|
||||
|
||||
const scratchDirs = []
|
||||
|
||||
async function artifactPair(fromBody = 'artifact-a', toBody = 'artifact-b') {
|
||||
const directory = await mkdtemp(path.join(os.tmpdir(), 'orca-installer-pair-proof-'))
|
||||
scratchDirs.push(directory)
|
||||
const fromPath = path.join(directory, 'orca-a.exe')
|
||||
const toPath = path.join(directory, 'orca-b.exe')
|
||||
await Promise.all([writeFile(fromPath, fromBody), writeFile(toPath, toBody)])
|
||||
return { fromPath, toPath }
|
||||
}
|
||||
|
||||
afterEach(async () => {
|
||||
await Promise.all(scratchDirs.splice(0).map((directory) => rm(directory, { recursive: true })))
|
||||
})
|
||||
|
||||
describe('packaged installer pair proof', () => {
|
||||
it('requires an explicit compatibility-gate flag', () => {
|
||||
const opts = parseArgs([
|
||||
'--from',
|
||||
'a.exe',
|
||||
'--to',
|
||||
'b.exe',
|
||||
'--expect',
|
||||
'cold-restore',
|
||||
'--require-distinct-artifacts'
|
||||
])
|
||||
|
||||
expect(opts.requireDistinctArtifacts).toBe(true)
|
||||
})
|
||||
|
||||
it('records distinct paths, versions, and hashes', async () => {
|
||||
const pair = await artifactPair()
|
||||
|
||||
const proof = await proveDistinctInstallerPair({
|
||||
...pair,
|
||||
fromVersion: '1.4.130',
|
||||
toVersion: '1.4.131'
|
||||
})
|
||||
|
||||
expect(proof.from.path).not.toBe(proof.to.path)
|
||||
expect(proof.from.version).not.toBe(proof.to.version)
|
||||
expect(proof.from.sha256).not.toBe(proof.to.sha256)
|
||||
})
|
||||
|
||||
it('fails closed for byte-identical artifacts at different paths', async () => {
|
||||
const pair = await artifactPair('same-artifact', 'same-artifact')
|
||||
|
||||
await expect(
|
||||
proveDistinctInstallerPair({
|
||||
...pair,
|
||||
fromVersion: '1.4.130',
|
||||
toVersion: '1.4.131'
|
||||
})
|
||||
).rejects.toThrow('SHA-256 hashes are identical')
|
||||
})
|
||||
|
||||
it('fails closed for an identical path or version', async () => {
|
||||
const pair = await artifactPair()
|
||||
|
||||
await expect(
|
||||
proveDistinctInstallerPair({
|
||||
fromPath: pair.fromPath,
|
||||
toPath: pair.fromPath,
|
||||
fromVersion: '1.4.130',
|
||||
toVersion: '1.4.130'
|
||||
})
|
||||
).rejects.toThrow(/paths are identical.*hashes are identical.*versions are identical/)
|
||||
})
|
||||
|
||||
it('fails closed when either package version is unavailable', async () => {
|
||||
const pair = await artifactPair()
|
||||
|
||||
await expect(
|
||||
proveDistinctInstallerPair({
|
||||
...pair,
|
||||
fromVersion: null,
|
||||
toVersion: '1.4.131'
|
||||
})
|
||||
).rejects.toThrow('both installer versions must be readable')
|
||||
})
|
||||
})
|
||||
@@ -12,7 +12,13 @@ import { execFileSync } from 'node:child_process'
|
||||
import { assertWin32 } from './platform-guard.mjs'
|
||||
import { parseArgs } from './cli-args.mjs'
|
||||
import { preflight } from './preflight.mjs'
|
||||
import { resolveInstaller, silentInstall, silentUninstall } from './installer-steps.mjs'
|
||||
import {
|
||||
getExeVersion,
|
||||
resolveInstaller,
|
||||
silentInstall,
|
||||
silentUninstall
|
||||
} from './installer-steps.mjs'
|
||||
import { proveDistinctInstallerPair } from './installer-pair-proof.mjs'
|
||||
import { backupInstallState, restoreInstallState } from './registry-shortcut-backup.mjs'
|
||||
import {
|
||||
launchInstalledApp,
|
||||
@@ -177,6 +183,24 @@ async function runProof(ctx, args) {
|
||||
releaseTag: opts.fromRelease,
|
||||
assetPattern: opts.assetPattern
|
||||
})
|
||||
const toInstaller = resolveInstaller({
|
||||
localPath: opts.to,
|
||||
releaseTag: opts.toRelease,
|
||||
assetPattern: opts.assetPattern
|
||||
})
|
||||
if (opts.requireDistinctArtifacts) {
|
||||
const artifactProof = await proveDistinctInstallerPair({
|
||||
fromPath: fromInstaller,
|
||||
toPath: toInstaller,
|
||||
fromVersion: getExeVersion(fromInstaller),
|
||||
toVersion: getExeVersion(toInstaller)
|
||||
})
|
||||
log(
|
||||
'artifact-proof',
|
||||
`A ${artifactProof.from.version} ${artifactProof.from.sha256}; ` +
|
||||
`B ${artifactProof.to.version} ${artifactProof.to.sha256}`
|
||||
)
|
||||
}
|
||||
log('install-base', `installing ${fromInstaller}`)
|
||||
const base = silentInstall(fromInstaller, { installDir })
|
||||
// Track the install now (not only after the update at L238) so a failure
|
||||
@@ -230,11 +254,6 @@ async function runProof(ctx, args) {
|
||||
log('watch', `started (duration ${watchDuration}s) -> ${watchOut}`)
|
||||
|
||||
// --- Update: install N+1 ---
|
||||
const toInstaller = resolveInstaller({
|
||||
localPath: opts.to,
|
||||
releaseTag: opts.toRelease,
|
||||
assetPattern: opts.assetPattern
|
||||
})
|
||||
log('update', `installing ${toInstaller}`)
|
||||
const updated = silentInstall(toInstaller, { installDir })
|
||||
// Record the exact dir the harness installed into so non-isolated teardown
|
||||
|
||||
Reference in New Issue
Block a user