The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(install-e2e): close macOS bundled-arm driver and helper defects
ethernet0decef9d09b2
diff --git a/tests-js/macos-bundled-helpers.test.mjs b/tests-js/macos-bundled-helpers.test.mjsindex eab98c70017..461f76cf1d5 100644--- a/tests-js/macos-bundled-helpers.test.mjs+++ b/tests-js/macos-bundled-helpers.test.mjs@@ -9,6 +9,7 @@ const require = createRequire(import.meta.url)const {validateBundleManifest,codesignTeam,+ channelFromTag,stampAssertions,} = require('../tests/install/e2e-assets/mac-bundled-manifest.cjs')@@ -16,7 +17,8 @@ const side = (over = {}) => ({tag: 'v0.28.0',version: '0.28.0',commit: 'a'.repeat(40),- identity: 'TEAM1234',+ identity: 'com.nousresearch.hermes-bundled',+ teamId: 'TEAM123456',artifact: { url: 'https://example.com/HermesBundled-0.28.0-mac-arm64.zip', sha256: 'b'.repeat(64), path: '/tmp/old.zip' },...over,})@@ -53,6 +55,21 @@ describe('validateBundleManifest', () => {expect(() => validateBundleManifest(manifest({ old: side({ commit: 'zz' }) }), want)).toThrow(/commit/)})+ it('requires an explicit teamId on BOTH sides (10-char signing team)', () => {+ expect(() => validateBundleManifest(manifest({ old: side({ teamId: undefined }) }), want)).toThrow(/teamId/)+ expect(() => validateBundleManifest(manifest({ old: side({ teamId: 'tooshort' }) }), want)).toThrow(/teamId/)+ expect(() => validateBundleManifest(manifest({ new: side({ teamId: 'OTHER99999', commit: 'c'.repeat(40) }) }), want)).toThrow(/Squirrel/)+ })++ it('treats identity as the exact CFBundleIdentifier, not a namespace', () => {+ expect(() => validateBundleManifest(manifest({ old: side({ identity: 'TEAM123456' }) }), want)).toThrow(/CFBundleIdentifier/)+ expect(() => validateBundleManifest(manifest({ old: side({ identity: 'com.nousresearch.hermes-bundled' }) }), want)).not.toThrow()+ expect(() => validateBundleManifest(+ manifest({ new: side({ identity: 'com.nousresearch.hermes-other', tag: 'v0.29.0', version: '0.29.0', commit: 'c'.repeat(40), artifact: { url: 'u', sha256: 'd'.repeat(64), path: '/tmp/n' } }) }),+ want,+ )).toThrow(/same application bundle/)+ })+it('requires the resolver to have downloaded the artifact', () => {expect(() => validateBundleManifest(manifest({ old: side({ artifact: { url: 'x', sha256: 'b'.repeat(64) } }) }), want,@@ -62,25 +79,38 @@ describe('validateBundleManifest', () => {)).toThrow(/sha256/)})- it('rejects a no-op pair and a team-changing pair (Squirrel gate)', () => {+ it('rejects a no-op pair and a channel-crossing pair', () => {expect(() => validateBundleManifest(manifest({ new: side() }), want)).toThrow(/no update/)expect(() => validateBundleManifest(- manifest({ new: side({ commit: 'c'.repeat(40), identity: 'OTHER999', tag: 'v0.29.0', version: '0.29.0', artifact: { url: 'u', sha256: 'd'.repeat(64), path: '/tmp/n' } }) }), want,- )).toThrow(/Squirrel/)+ manifest({ new: side({ tag: 'v0.29.0-canary.20260907000000', version: '0.29.0-canary.20260907000000', commit: 'c'.repeat(40), artifact: { url: 'u', sha256: 'd'.repeat(64), path: '/tmp/n' } }) }),+ want,+ )).toThrow(/channel/)+ })+})++describe('channelFromTag', () => {+ it('maps canary tags to the canary channel, everything else to stable', () => {+ expect(channelFromTag('v0.29.0-canary.20260907000000')).toBe('canary')+ expect(channelFromTag('v0.29.0')).toBe('stable')})})describe('codesignTeam', () => {- it('parses the team from codesign -dv output', () => {+ it('parses the team from codesign -dv STDERR output', () => {const out = [- 'Executable=/tmp/Hermes.app/Contents/MacOS/Hermes',+ 'Executable=/tmp/Hermes Bundled.app/Contents/MacOS/Hermes Bundled','Identifier=com.nousresearch.hermes-bundled',- 'TeamIdentifier=TEAM1234',+ 'TeamIdentifier=TEAM123456',].join('\n')- expect(codesignTeam(out)).toBe('TEAM1234')+ expect(codesignTeam(out)).toBe('TEAM123456')})- it('returns null when unsigned', () => {+ it('returns null for unsigned / ad-hoc signatures', () => {expect(codesignTeam('Identifier=com.x\nTeamIdentifier=not set')).toBeNull()+ expect(codesignTeam('Identifier=com.x\nTeamIdentifier=')).toBeNull()+ expect(codesignTeam('')).toBeNull()+ })+ it('never matches the word "not" as a team id', () => {+ expect(codesignTeam('TeamIdentifier=not set\nFoo=not')).toBeNull()})})@@ -114,22 +144,26 @@ describe('stampAssertions', () => {describe('mac-bundled-feed materializer', () => {it('emits the production update-feed contract for the real NEW zip', async () => {- const { materializeFeed, feedFileNames } = await import('../tests/install/e2e-assets/mac-bundled-feed.mjs')+ const { materializeFeed, feedFileNames, sha512Base64 } = await import('../tests/install/e2e-assets/mac-bundled-feed.mjs')const { createHash } = await import('node:crypto')// The feed layout comes from the ONE production contract, not a copy.const { darwinFeed } = require('../apps/desktop/update-feed.cjs')expect(darwinFeed('stable').directory).toBe('releases/darwin/stable')- expect(feedFileNames('arm64').prefixed).toBe('arm64-stable-mac.yml')- expect(feedFileNames('x64').prefixed).toBe('stable-mac.yml')+ expect(feedFileNames('arm64', 'stable').prefixed).toBe('arm64-stable-mac.yml')+ expect(feedFileNames('x64', 'stable').prefixed).toBe('stable-mac.yml')+ expect(feedFileNames('arm64', 'canary').directory).toBe('releases/darwin/canary')+ expect(feedFileNames('arm64', 'canary').prefixed).toBe('arm64-canary-mac.yml')const outDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mac-feed-'))const zip = path.join(outDir, 'HermesBundled-0.29.0-mac-arm64.zip')const zipBytes = Buffer.from('fake signed zip for feed shape tests')fs.writeFileSync(zip, zipBytes)const expectedSha512 = createHash('sha512').update(zipBytes).digest('base64')+ // The streamed hash matches a whole-buffer hash (streams, no full read).+ expect(await sha512Base64(zip)).toBe(expectedSha512)- const receipt = materializeFeed({+ const receipt = await materializeFeed({outDir,zipPath: zip,version: '0.29.0',@@ -138,7 +172,8 @@ describe('mac-bundled-feed materializer', () => {releaseDate: '2026-09-07T00:00:00.000Z',})- // The artifact is served under the merged production URL shape.+ // The channel comes from the tag, never a hard-coded 'stable'.+ expect(receipt.channel).toBe('stable')expect(receipt.artifactUrlPath).toBe('/releases/tag/v0.29.0/HermesBundled-0.29.0-mac-arm64.zip')expect(receipt.written).toEqual(['releases/darwin/stable/arm64-stable-mac.yml',@@ -155,4 +190,33 @@ describe('mac-bundled-feed materializer', () => {expect(fs.readFileSync(path.join(outDir, 'releases/tag/v0.29.0/HermesBundled-0.29.0-mac-arm64.zip'))).toEqual(zipBytes)})++ it('serves canary tags from the canary channel directory', async () => {+ const { materializeFeed } = await import('../tests/install/e2e-assets/mac-bundled-feed.mjs')+ const outDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mac-feed-canary-'))+ const zip = path.join(outDir, 'HermesBundled-0.30.0-canary-mac-arm64.zip')+ fs.writeFileSync(zip, 'canary zip')+ const receipt = await materializeFeed({+ outDir, zipPath: zip, version: '0.30.0',+ tag: 'v0.30.0-canary.20260907000000', arch: 'x64',+ releaseDate: '2026-09-07T00:00:00.000Z',+ })+ expect(receipt.channel).toBe('canary')+ expect(receipt.feedKey).toBe('releases/darwin/canary/canary-mac.yml')+ expect(fs.existsSync(path.join(outDir, 'releases/darwin/canary/canary-mac.yml'))).toBe(true)+ expect(fs.existsSync(path.join(outDir, 'releases/darwin/canary/arm64-canary-mac.yml'))).toBe(false)+ })+})++describe('mac-bundled-serve path safety', () => {+ it('resolves in-root paths and rejects traversal outside the feed root', async () => {+ const { safeJoin } = await import('../tests/install/e2e-assets/mac-bundled-serve.mjs')+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'mac-serve-'))+ expect(safeJoin(root, '/releases/darwin/stable/stable-mac.yml'))+ .toBe(path.join(root, 'releases/darwin/stable/stable-mac.yml'))+ // Classic traversal: the old startsWith(root) check passed these.+ expect(safeJoin(root, '/../escape.yml')).toBeNull()+ expect(safeJoin(root, '/%2e%2e/escape.yml')).toBeNull()+ expect(safeJoin(root, '/..%2fescape.yml')).toBeNull()+ })})diff --git a/tests/install/e2e-assets/mac-bundled-feed.mjs b/tests/install/e2e-assets/mac-bundled-feed.mjsindex 3e30f28d078..560f4f5e7ff 100644--- a/tests/install/e2e-assets/mac-bundled-feed.mjs+++ b/tests/install/e2e-assets/mac-bundled-feed.mjs@@ -1,3 +1,4 @@+#!/usr/bin/env node'use strict'// mac-bundled-feed.mjs — build the loopback static update feed for the// macOS packaged-app -> open-app-update E2E arm from the REAL signed NEW@@ -10,21 +11,33 @@// merged url /releases/tag/<tag>/<artifact>.zip// A release publishes the MERGED feed (both arches merged by// r2-release.mjs finalize). electron-updater on arm64 requests-// arm64-stable-mac.yml; on x64 it requests stable-mac.yml. This controlled-// single-arch loopback feed emits the same merged shape and serves both-// request names with identical bytes.+// <arch>-<channel>-mac.yml; on x64 it requests <channel>-mac.yml. The+// channel comes from the release TAG (canary tags serve canary feeds) —+// never hard-coded — and must be identical on both manifest sides+// (validated in mac-bundled-manifest.cjs).import { createHash } from 'node:crypto'import fs from 'node:fs'import path from 'node:path'+import { createReadStream } from 'node:fs'+import { pipeline } from 'node:stream/promises'import { createRequire } from 'node:module'const require = createRequire(import.meta.url)// The one feed-layout contract, straight from the production source.const { darwinFeed } = require('../../../apps/desktop/update-feed.cjs')-export function sha512Base64(filePath) {- return createHash('sha512').update(fs.readFileSync(filePath)).digest('base64')+/** sha512 of a file, base64 — STREAMED: release zips are hundreds of MB+ * and must never be read whole into memory. */+export async function sha512Base64(filePath) {+ const hash = createHash('sha512')+ await pipeline(createReadStream(filePath), async function* (source) {+ for await (const chunk of source) {+ hash.update(chunk)+ yield chunk+ }+ })+ return hash.digest('base64')}/**@@ -48,31 +61,34 @@ export function buildMacFeedText({ version, tag, zipName, sha512, size, releaseDreturn lines.join('\n')}-/** The feed file names electron-updater asks for on this arch (and the- * un-prefixed name, served too so the merged-feed contract holds). */-export function feedFileNames(arch) {- const feed = darwinFeed('stable')+/** The feed file names electron-updater asks for on this arch, on this+ * channel (and the un-prefixed name, served too so the merged-feed+ * contract holds). */+export function feedFileNames(arch, channel = 'stable') {+ const feed = darwinFeed(channel)const prefixed = arch === 'x64' ? feed.fileName : `${arch}-${feed.fileName}`return { feed, prefixed, plain: feed.fileName, directory: feed.directory }}/**- * Materialize the loopback feed directory:- * <out>/releases/darwin/stable/{arm64-,}stable-mac.yml+ * Materialize the loopback feed directory for the channel the NEW tag+ * publishes to:+ * <out>/releases/darwin/<channel>/{arm64-,}<channel>-mac.yml* <out>/releases/tag/<tag>/<zipName> (copy of the real NEW zip)* Returns a receipt for the driver to assert.*/-export function materializeFeed({ outDir, zipPath, version, tag, arch, releaseDate }) {+export async function materializeFeed({ outDir, zipPath, version, tag, arch, releaseDate }) {const zipStat = fs.statSync(zipPath)if (zipStat.size <= 0) throw new Error(`feed: empty zip at ${zipPath}`)const zipName = path.basename(zipPath)if (!zipName.endsWith('.zip')) {throw new Error(`feed: expected a .zip artifact, got ${zipName}`)}- const sha512 = sha512Base64(zipPath)+ const channel = tag.includes('-canary.') ? 'canary' : 'stable'+ const sha512 = await sha512Base64(zipPath)const text = buildMacFeedText({ version, tag, zipName, sha512, size: zipStat.size, releaseDate })- const { prefixed, plain, directory } = feedFileNames(arch)+ const { prefixed, plain, directory } = feedFileNames(arch, channel)const feedDir = path.join(outDir, directory)fs.mkdirSync(feedDir, { recursive: true })const written = []@@ -88,7 +104,7 @@ export function materializeFeed({ outDir, zipPath, version, tag, arch, releaseDaconst artifactDest = path.join(artifactDir, zipName)fs.copyFileSync(zipPath, artifactDest)- return { feedKey: `${directory}/${prefixed}`, written, artifactUrlPath: `/releases/tag/${tag}/${zipName}`, sha512, size: zipStat.size, version, tag }+ return { feedKey: `${directory}/${prefixed}`, channel, written, artifactUrlPath: `/releases/tag/${tag}/${zipName}`, sha512, size: zipStat.size, version, tag }}// CLI entry: node mac-bundled-feed.mjs --out DIR --zip FILE --version V \@@ -104,7 +120,7 @@ if (process.argv.length > 2 && process.argv[1].endsWith('mac-bundled-feed.mjs'))arch: { type: 'string' },},})- const receipt = materializeFeed({+ const receipt = await materializeFeed({outDir: values.out,zipPath: values.zip,version: values.version,diff --git a/tests/install/e2e-assets/mac-bundled-manifest.cjs b/tests/install/e2e-assets/mac-bundled-manifest.cjsindex 1172a341e03..49f471b8a5e 100644--- a/tests/install/e2e-assets/mac-bundled-manifest.cjs+++ b/tests/install/e2e-assets/mac-bundled-manifest.cjs@@ -1,3 +1,4 @@+#!/usr/bin/env node'use strict'// mac-bundled-manifest.cjs — pure validation/assertion helpers for the// macOS packaged-app -> open-app-update E2E arm@@ -5,23 +6,32 @@// everything here is requireable from vitest (tests-js) and from the// driver's node invocations on the macOS runner.//-// The bundle manifest itself is resolved by the PARENT-owned common-// resolver: tests/install/e2e-assets/bundle-inputs.mjs-// --manifest-url URL --platform macos --arch arm64|x64 --out WORKROOT-// which validates remote bytes (commits, versions, sha256) and writes-// WORKROOT/bundle-inputs.json with old/new.artifact.path added (local-// downloaded artifact). This module only asserts the normalized result.+// The bundle manifest itself is RESOLVED by the PARENT-owned common+// resolver tests/install/e2e-assets/bundle-inputs.mjs (schema/commit/+// sha256/semver validation + artifact download). This module asserts the+// macOS-specific semantics on the resolver's normalized output+// (WORKROOT/bundle-inputs.json): per-side teamId + CFBundleIdentifier,+// exact-identity update rules, and channel consistency.const ARCHES = ['arm64', 'x64']const SHA256_RE = /^[0-9a-f]{64}$/// stable tags: vX.Y.Z; canary: vX.Y.Z-canary.YYYYMMDDHHMMSSconst TAG_RE = /^v\d+\.\d+\.\d+(?:-canary\.20\d{6}(?:\d{6})?)?$/+// CFBundleIdentifier shape (exact match is enforced at verify time; this+// only rejects obvious junk).+const BUNDLE_ID_RE = /^[A-Za-z][A-Za-z0-9-]+(\.[A-Za-z0-9-]+)+$/++/** The update channel a release tag publishes to (the production+ * darwinFeed channel). Canary tags feed the canary channel. */+function channelFromTag(tag) {+ return /-canary\./.test(String(tag)) ? 'canary' : 'stable'+}function validateSide(side, label) {if (!side || typeof side !== 'object') {throw new Error(`${label}: missing side object`)}- for (const key of ['tag', 'version', 'commit', 'identity']) {+ for (const key of ['tag', 'version', 'commit', 'identity', 'teamId']) {if (typeof side[key] !== 'string' || !side[key]) {throw new Error(`${label}.${key}: expected a non-empty string`)}@@ -35,6 +45,16 @@ function validateSide(side, label) {if (!/^[0-9a-f]{40}$/.test(side.commit)) {throw new Error(`${label}.commit: expected a 40-hex SHA, got ${JSON.stringify(side.commit)}`)}+ // identity IS the CFBundleIdentifier (not the team): verified exactly,+ // never by namespace prefix.+ if (!BUNDLE_ID_RE.test(side.identity)) {+ throw new Error(`${label}.identity: ${JSON.stringify(side.identity)} is not a CFBundleIdentifier`)+ }+ // Same rule the common resolver enforces (bundle-inputs.mjs): an exact+ // 10-char Apple signing team id.+ if (!/^[A-Z0-9]{10}$/.test(side.teamId)) {+ throw new Error(`${label}.teamId: ${JSON.stringify(side.teamId)} is not a 10-char signing team id`)+ }const artifact = side.artifactif (!artifact || typeof artifact !== 'object') {throw new Error(`${label}.artifact: missing object`)@@ -78,30 +98,41 @@ function validateBundleManifest(manifest, want) {throw new Error('old.commit == new.commit: no update would be available')}if (manifest.old.identity !== manifest.new.identity) {- // Squirrel.Mac refuses an update whose code signature changes team.+ // The updater only replaces a bundle whose CFBundleIdentifier matches.throw new Error(`old.identity ${manifest.old.identity} != new.identity ${manifest.new.identity}: ` ++ 'not the same application bundle')+ }+ if (manifest.old.teamId !== manifest.new.teamId) {+ // Squirrel.Mac refuses an update whose code signature changes team.+ throw new Error(+ `old.teamId ${manifest.old.teamId} != new.teamId ${manifest.new.teamId}: ` +'Squirrel.Mac would reject this pair (signature gate)')}+ if (channelFromTag(manifest.old.tag) !== channelFromTag(manifest.new.tag)) {+ throw new Error(+ `channel mismatch: old tag ${manifest.old.tag} vs new tag ${manifest.new.tag} — ` ++ 'the update must stay on one feed channel')+ }return manifest}-/** Parse the TeamIdentifier line out of `codesign -dv` output. */+/**+ * Parse the TeamIdentifier out of `codesign -dv` output. codesign prints+ * display output on STDERR, so pass stderr (or combined output) here.+ * Returns null for an unsigned / ad-hoc ("not set") signature.+ */function codesignTeam(codesignOutput) {- const match = /TeamIdentifier=(?:not set|=)?\s*([A-Z0-9]+)/.exec(codesignOutput)- return match ? match[1] : null-}--/** True when `codesign --verify` output reports a valid signature. */-function codesignValid(verifyOutput) {- return /validated/.test(verifyOutput)+ const match = /^TeamIdentifier=(.*)$/m.exec(String(codesignOutput || ''))+ if (!match) return null+ const value = match[1].trim()+ if (!value || value === 'not set' || value === '-') return null+ return value}-/**- * Assertions for an installed bundle's install-stamp.json+/** Assertions for an installed bundle's install-stamp.json* (Contents/Resources/install-stamp.json) against a manifest side.- * Mirrors apps/desktop/scripts/write-build-stamp.mjs's bundled shape.- */+ * Mirrors apps/desktop/scripts/write-build-stamp.mjs's bundled shape. */function stampAssertions(stamp, side) {const problems = []if (!stamp || typeof stamp !== 'object') {@@ -125,4 +156,10 @@ function stampAssertions(stamp, side) {return problems}-module.exports = { ARCHES, validateBundleManifest, codesignTeam, codesignValid, stampAssertions }+module.exports = {+ ARCHES,+ channelFromTag,+ validateBundleManifest,+ codesignTeam,+ stampAssertions,+}diff --git a/tests/install/e2e-assets/mac-bundled-serve.mjs b/tests/install/e2e-assets/mac-bundled-serve.mjsindex b028da89c3f..03a612b9c9d 100644--- a/tests/install/e2e-assets/mac-bundled-serve.mjs+++ b/tests/install/e2e-assets/mac-bundled-serve.mjs@@ -5,57 +5,80 @@// mac-bundled-feed.mjs over 127.0.0.1, logs every request to a JSONL file// (the proof the app really fetched THIS feed), and stays up until killed.//-// Usage: node mac-bundled-serve.mjs --dir <feed-dir> --port <port> \-// --log <requests.jsonl> [--health /__healthz]+// --port 0 (the default) binds an ephemeral port; the ACTUAL port is+// written as JSON to --ready once listening, so the driver configures the+// app with the real URL instead of a hard-coded one.+//+// Usage: node mac-bundled-serve.mjs --dir <feed-dir> [--port 0] \+// --log <requests.jsonl> [--health /__healthz] [--ready <json>]import http from 'node:http'import fs from 'node:fs'import path from 'node:path'+import { pathToFileURL } from 'node:url'import { parseArgs } from 'node:util'-const { values } = parseArgs({- options: {- dir: { type: 'string' },- port: { type: 'string' },- log: { type: 'string' },- health: { type: 'string', default: '/__healthz' }- }-})--const root = path.resolve(values.dir)-if (!fs.existsSync(root)) {- console.error(`feed dir not found: ${root}`)- process.exit(1)+/** Resolve `pathname` inside `root`, rejecting any path that escapes it+ * (path traversal). Returns null when the target is outside the root. */+export function safeJoin(root, pathname) {+ const target = path.resolve(root, '.' + decodeURIComponent(pathname))+ const rel = path.relative(path.resolve(root), target)+ if (!rel || rel.startsWith('..') || path.isAbsolute(rel)) return null+ return target}-const logStream = values.log ? fs.createWriteStream(values.log, { flags: 'a' }) : null-const server = http.createServer((req, res) => {- const url = new URL(req.url, `http://127.0.0.1:${values.port}`)- if (logStream) {- logStream.write(JSON.stringify({ t: Date.now(), path: url.pathname, ua: req.headers['user-agent'] || '' }) + '\n')- }- if (url.pathname === values.health) {- res.writeHead(200, { 'content-type': 'text/plain' })- res.end('ok\n')- return- }- const target = path.resolve(root, '.' + decodeURIComponent(url.pathname))- if (!target.startsWith(root) || !fs.existsSync(target) || !fs.statSync(target).isFile()) {- res.writeHead(404, { 'content-type': 'text/plain' })- res.end('not found\n')- return+const invokedDirectly = process.argv[1] &&+ import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href++if (invokedDirectly) {+ const { values } = parseArgs({+ options: {+ dir: { type: 'string' },+ port: { type: 'string', default: '0' },+ log: { type: 'string' },+ health: { type: 'string', default: '/__healthz' },+ ready: { type: 'string' },+ }+ })++ const root = path.resolve(values.dir)+ if (!fs.existsSync(root)) {+ console.error(`feed dir not found: ${root}`)+ process.exit(1)}- // no-store: the updater must always see the live feed, never a cache.- res.writeHead(200, {- 'content-type': target.endsWith('.yml') ? 'text/yaml; charset=utf-8' : 'application/zip',- 'content-length': fs.statSync(target).size,- 'cache-control': 'no-store'+ const logStream = values.log ? fs.createWriteStream(values.log, { flags: 'a' }) : null++ const server = http.createServer((req, res) => {+ const url = new URL(req.url, 'http://127.0.0.1')+ if (logStream) {+ logStream.write(JSON.stringify({ t: Date.now(), path: url.pathname, ua: req.headers['user-agent'] || '' }) + '\n')+ }+ if (url.pathname === values.health) {+ res.writeHead(200, { 'content-type': 'text/plain' })+ res.end('ok\n')+ return+ }+ const target = safeJoin(root, url.pathname)+ if (!target || !fs.existsSync(target) || !fs.statSync(target).isFile()) {+ res.writeHead(404, { 'content-type': 'text/plain' })+ res.end('not found\n')+ return+ }+ // no-store: the updater must always see the live feed, never a cache.+ res.writeHead(200, {+ 'content-type': target.endsWith('.yml') ? 'text/yaml; charset=utf-8' : 'application/zip',+ 'content-length': fs.statSync(target).size,+ 'cache-control': 'no-store'+ })+ fs.createReadStream(target).pipe(res)})- fs.createReadStream(target).pipe(res)-})-// Loopback only, by construction and by policy: the production updater-// accepts loopback HTTP overrides exclusively (mac-client.ts).-server.listen(Number(values.port), '127.0.0.1', () => {- console.log(`serving ${root} on http://127.0.0.1:${values.port}`)-})+ // Loopback only, by construction and by policy: the production updater+ // accepts loopback HTTP overrides exclusively (mac-client.ts).+ server.listen(Number(values.port), '127.0.0.1', () => {+ const port = server.address().port+ const receipt = { port, url: `http://127.0.0.1:${port}`, root }+ if (values.ready) fs.writeFileSync(values.ready, JSON.stringify(receipt) + '\n')+ console.log(`serving ${root} on http://127.0.0.1:${port}`)+ })+}diff --git a/tests/install/e2e-assets/mac-bundled-verify.mjs b/tests/install/e2e-assets/mac-bundled-verify.mjsindex 0a51e8519a1..44ceb57b551 100644--- a/tests/install/e2e-assets/mac-bundled-verify.mjs+++ b/tests/install/e2e-assets/mac-bundled-verify.mjs@@ -1,26 +1,28 @@#!/usr/bin/env node'use strict'// mac-bundled-verify.mjs — verify an INSTALLED macOS bundle on the runner:-// real codesign validation, team identity, bundle version, and the baked-// install stamp, against a manifest side from bundle-inputs.json. Parses-// success receipts — file existence is never success.+// real codesign validation, BOTH signing identifiers (CFBundleIdentifier+// exactly, TeamIdentifier exactly), the bundle version, the lipo arch, and+// the baked install stamp, against a manifest side from bundle-inputs.json.+// Parses success receipts — file existence is never success.//-// macOS-only (codesign/plutil). Pure assertion logic lives in+// macOS-only (codesign/plutil/lipo). Pure assertion logic lives in// mac-bundled-manifest.cjs and is covered by tests-js.//// Usage:// node mac-bundled-verify.mjs verify-app --app <path> \// --expect-version 1.2.3 --expect-commit <sha> --expect-tag vX.Y.Z \-// --expect-identity <team-id> [--out <receipt.json>]+// --expect-identity <CFBundleIdentifier> --expect-team <TeamID> \+// --expect-arch arm64|x64 [--out <receipt.json>]-import { execFileSync } from 'node:child_process'+import { execFileSync, spawnSync } from 'node:child_process'import fs from 'node:fs'import path from 'node:path'import { parseArgs } from 'node:util'import { createRequire } from 'node:module'const require = createRequire(import.meta.url)-const { codesignTeam, codesignValid, stampAssertions } = require('./mac-bundled-manifest.cjs')+const { codesignTeam, stampAssertions } = require('./mac-bundled-manifest.cjs')const [, , command, ...rest] = process.argv@@ -29,6 +31,25 @@ function fail(message) {process.exit(1)}+// codesign -dv prints its DISPLAY output on STDERR (stdout stays empty),+// so capture both streams and hand the combined text to the parser.+function codesignDisplay(app) {+ const result = spawnSync('codesign', ['-dv', app], { encoding: 'utf8' })+ const text = `${result.stdout || ''}\n${result.stderr || ''}`+ if (result.status !== 0 && !text.trim()) {+ fail(`codesign -dv failed for ${app}: ${result.stderr || result.error}`)+ }+ return text+}++// lipo -archs prints e.g. "arm64" or "x86_64" (space-separated for+// universal binaries) on stdout.+function bundleArchs(executable) {+ return execFileSync('lipo', ['-archs', executable], { encoding: 'utf8' }).split(/\s+/).filter(Boolean)+}++const ARCH_TOKENS = { arm64: 'arm64', x64: 'x86_64' }+function verifyApp() {const { values } = parseArgs({strict: false,@@ -39,6 +60,8 @@ function verifyApp() {'expect-commit': { type: 'string' },'expect-tag': { type: 'string' },'expect-identity': { type: 'string' },+ 'expect-team': { type: 'string' },+ 'expect-arch': { type: 'string' },out: { type: 'string' },},})@@ -55,33 +78,54 @@ function verifyApp() {fail(`codesign --verify rejected ${app}: ${String(error.stderr || error)}`)}- // 2. The signing team matches the manifest identity. Squirrel.Mac only- // accepts an update signed by the SAME team — this assertion is what- // makes the pair updatable at all.- const displayOut = execFileSync('codesign', ['-dv', app], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] })+ // 2. BOTH identifiers, exactly (no namespace prefix acceptance):+ // - the signing TEAM must match the manifest teamId — Squirrel.Mac+ // only accepts an update signed by the SAME team;+ // - the CFBundleIdentifier must equal the manifest identity — the+ // updater only replaces the same application bundle.+ const displayOut = codesignDisplay(app)const team = codesignTeam(displayOut)if (!team) fail(`no TeamIdentifier in codesign -dv output for ${app}`)- if (team !== values['expect-identity']) {- fail(`codesign TeamIdentifier ${team} != manifest identity ${values['expect-identity']}`)+ if (team !== values['expect-team']) {+ fail(`codesign TeamIdentifier ${team} != manifest teamId ${values['expect-team']}`)}- // 3. Bundle version and identifier from the real Info.plist.+ // 3. Bundle version, identifier and executable from the real Info.plist.const plist = JSON.parse(execFileSync('plutil', ['-convert', 'json', '-o', '-', path.join(app, 'Contents', 'Info.plist')], { encoding: 'utf8' }))const receipt = {app,teamIdentifier: team,bundleVersion: plist.CFBundleShortVersionString,bundleIdentifier: plist.CFBundleIdentifier,+ executable: plist.CFBundleExecutable,verifiedAt: new Date().toISOString(),}if (receipt.bundleVersion !== values['expect-version']) {fail(`CFBundleShortVersionString ${receipt.bundleVersion} != expected ${values['expect-version']}`)}- if (!String(receipt.bundleIdentifier).startsWith('com.nousresearch.')) {- fail(`CFBundleIdentifier ${receipt.bundleIdentifier} is not a Hermes product bundle id`)+ // The manifest identity IS the CFBundleIdentifier: exact equality.+ if (receipt.bundleIdentifier !== values['expect-identity']) {+ fail(`CFBundleIdentifier ${receipt.bundleIdentifier} != manifest identity ${values['expect-identity']}`)+ }++ // 4. The executable the plist NAMES must exist — the update driver and+ // watcher launch exactly this path (never a hard-coded binary name).+ const execPath = path.join(app, 'Contents', 'MacOS', String(receipt.executable))+ if (!receipt.executable || !fs.existsSync(execPath)) {+ fail(`no executable at ${execPath} (CFBundleExecutable=${receipt.executable})`)+ }+ receipt.executablePath = execPath++ // 5. The installed bundle really IS built for the leg's architecture.+ const archs = bundleArchs(execPath)+ receipt.lipoArchs = archs+ const wantToken = ARCH_TOKENS[values['expect-arch']]+ if (!wantToken) fail(`--expect-arch must be arm64 or x64, got ${values['expect-arch']}`)+ if (!archs.includes(wantToken)) {+ fail(`lipo -archs of ${execPath} is [${archs.join(', ')}]; expected ${wantToken} for ${values['expect-arch']}`)}- // 4. The baked install stamp (provenance: commit, tag, payload, mechanism).+ // 6. The baked install stamp (provenance: commit, tag, payload, mechanism).const stampPath = path.join(app, 'Contents', 'Resources', 'install-stamp.json')if (!fs.existsSync(stampPath)) fail(`no install stamp at ${stampPath}`)const stamp = JSON.parse(fs.readFileSync(stampPath, 'utf8'))diff --git a/tests/install/macos-bundled-e2e.sh b/tests/install/macos-bundled-e2e.shindex cd52caacadc..119f3ad0f2b 100644--- a/tests/install/macos-bundled-e2e.sh+++ b/tests/install/macos-bundled-e2e.sh@@ -6,22 +6,27 @@## Sibling of tests/install/macos-desktop-e2e.sh (the dmg/source arm). This# arm has NO git redirect, NO staging, NO patching or re-signing: both-# bundles are the actual release zips resolved by the PARENT-owned common-# manifest resolver (tests/install/e2e-assets/bundle-inputs.mjs), which-# validates commits, versions and sha256 and downloads the artifacts.+# bundles are the actual release zips resolved and downloaded by the+# PARENT-owned common resolver (tests/install/e2e-assets/bundle-inputs.mjs),+# which validates commits, versions, identities (CFBundleIdentifier ++# teamId), channels and sha256.## Phases (state shared via the workroot):-# install resolve the bundle manifest, verify artifact sha256, unzip the-# REAL signed OLD zip into an isolated .app location, verify-# codesign / team identity / version / stamp, seed isolated user-# state + plugin fixtures+# install resolve the bundle manifest with the common resolver, verify+# artifact sha256, unzip the REAL signed OLD zip into an+# isolated .app location, derive the executable from its+# Info.plist (never a hard-coded binary name), verify codesign /+# BOTH identifiers / version / arch / stamp, record the install+# receipt for the update phase, seed isolated user state# update build the loopback static feed from the REAL signed NEW zip in-# the production update-feed contract, configure-# updates.desktop_feed_base_url, start the external relaunch-# watcher, click the real About -> "Update now" under Playwright,-# then verify the automatic relaunch (new pid/birth/path), the-# NEW bundle's codesign/version/stamp, backend health, plugin-# and user-state survival+# the production update-feed contract on the tag's channel,+# serve it on an ephemeral port (readiness JSON carries the+# real port), configure updates.desktop_feed_base_url, start+# the external relaunch watcher, click the real About ->+# "Update now" under Playwright, then verify the automatic+# relaunch (new pid/birth/path), the NEW bundle's codesign/+# identifiers/version/arch/stamp, backend health, plugin and+# user-state survival## Usage:# tests/install/macos-bundled-e2e.sh --phase install|update|all@@ -50,7 +55,7 @@ while [ "$#" -gt 0 ]; do--arch)[ "$#" -ge 2 ] || { echo 'error: --arch needs a value' >&2; exit 1; }ARCH="$2"; shift 2 ;;- -h|--help) sed -n '2,30p' "$0"; exit 0 ;;+ -h|--help) sed -n '2,40p' "$0"; exit 0 ;;*) echo "error: unknown argument: $1" >&2; exit 1 ;;esacdone@@ -64,11 +69,15 @@ case "$ARCH" in arm64|x64) ;; *) echo "error: --arch must be arm64 or x64" >&2;REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"ASSETS="$REPO_ROOT/tests/install/e2e-assets"export TS_BASE=$SECONDS+NODE_BIN="$(command -v node)"WORK_ROOT="${HERMES_E2E_WORKROOT:-${RUNNER_TEMP:-${TMPDIR:-/tmp}}/hermes-bundled-e2e}"LOG_DIR="${HERMES_E2E_LOG_DIR:-$WORK_ROOT/logs}"-export HOME_SANDBOX="$WORK_ROOT/home"+HOME_SANDBOX="$WORK_ROOT/home"+export HOME_SANDBOXexport HERMES_HOME="$HOME_SANDBOX/.hermes"+export HOME="$HOME_SANDBOX" # the app must see the ISOLATED home, not the runner's+mkdir -p "$WORK_ROOT" "$LOG_DIR" "$HOME_SANDBOX" "$HERMES_HOME"step() { printf '\n=== %s ===\n' "$*"; }ok() { printf ' OK %s\n' "$*"; }@@ -84,17 +93,27 @@ log_group() {}MANIFEST="$WORK_ROOT/bundle-inputs.json"-OLD_APP="$WORK_ROOT/apps/Hermes.app"-OLD_APP_BIN="$OLD_APP/Contents/MacOS/Hermes"+INSTALL_RECEIPT="$WORK_ROOT/install-receipt.json"FEED_DIR="$WORK_ROOT/feed"-FEED_PORT="${HERMES_E2E_FEED_PORT:-8791}"-FEED_URL="http://127.0.0.1:$FEED_PORT"-CONFIG_FEED_LINE=" desktop_feed_base_url: $FEED_URL"+# Port 0 = ephemeral: the server writes the ACTUAL port to a readiness+# JSON, and the driver configures the app from that (no fixed 8791).+FEED_READY="$LOG_DIR/feed-ready.json"export E2E_ARCH="$ARCH"+# Background PIDs are GLOBALS so the EXIT trap can kill them from any+# scope, on success AND on failure paths (no watcher/server leak).+SERVE_PID=""+WATCHER_PID=""+cleanup() {+ if [ -n "$WATCHER_PID" ]; then kill "$WATCHER_PID" 2>/dev/null || true; fi+ if [ -n "$SERVE_PID" ]; then kill "$SERVE_PID" 2>/dev/null || true; fi+ if declare -F mock_stop >/dev/null 2>&1; then mock_stop 2>/dev/null || true; fi+}+trap cleanup EXIT+manifest_side() { # $1: old|new, $2: field- node -e '+ "$NODE_BIN" -e 'const fs = require("node:fs")const m = JSON.parse(fs.readFileSync(process.argv[1], "utf8"))const side = m[process.argv[2]]@@ -104,31 +123,61 @@ manifest_side() { # $1: old|new, $2: fieldrequire_manifest() {[ -f "$MANIFEST" ] || fail "no bundle manifest at $MANIFEST — run the install phase first"- # Validate the parent resolver's output shape for this arm (schema 1,- # platform macos, this arch, real paths present, old != new, same team).- node -e '+ # Assert the common resolver's normalized output for this arm (schema 1,+ # platform macos, this arch, downloaded artifacts, old != new, SAME+ # CFBundleIdentifier, SAME teamId, same feed channel). The heavy schema/+ # semver/sha256 validation already happened inside bundle-inputs.mjs.+ "$NODE_BIN" -e 'const fs = require("node:fs")const { validateBundleManifest } = require(process.argv[2])const m = JSON.parse(fs.readFileSync(process.argv[1], "utf8"))validateBundleManifest(m, { platform: "macos", arch: process.env.E2E_ARCH })- console.log("bundle manifest valid: " + m.old.tag + " -> " + m.new.tag)- ' "$MANIFEST" "$ASSETS/mac-bundled-manifest.cjs"+ console.log("bundle manifest valid: " + m.old.tag + " -> " + m.new.tag ++ " (identity " + m.old.identity + ", team " + m.old.teamId + ")")+ ' "$MANIFEST" "$ASSETS/mac-bundled-manifest.cjs" 2>&1 | ts_prefix+}++stage_bundle_inputs() {+ [ -n "$MANIFEST_URL" ] || fail "--manifest-url is required for the bundled arm"+ step "resolving the bundle manifest with the common resolver"+ # bundle-inputs.mjs imports semver (declared in the repo root+ # package.json); the checkout on the runner has node_modules via CI setup.+ rm -f "$MANIFEST"+ mkdir -p "$WORK_ROOT"+ "$NODE_BIN" "$ASSETS/bundle-inputs.mjs" \+ --manifest-url "$MANIFEST_URL" --platform macos --arch "$ARCH" \+ --out "$WORK_ROOT" 2>&1 | ts_prefix | tee "$LOG_DIR/bundle-inputs.log"+ ok "bundle inputs staged at $MANIFEST"+}++# Derive the executable from the bundle's own Info.plist — the product+# name is NOT assumed to be "Hermes" (packaged name: "Hermes Bundled") and+# nothing is renamed. Returns the absolute binary path.+derive_app_bin() { # $1: .app path+ local exec_name+ exec_name="$(plutil -extract CFBundleExecutable raw -o - "$1/Contents/Info.plist")"+ [ -n "$exec_name" ] || fail "CFBundleExecutable missing in $1/Contents/Info.plist"+ local bin="$1/Contents/MacOS/$exec_name"+ [ -x "$bin" ] || fail "no executable at $bin (CFBundleExecutable=$exec_name)"+ printf '%s' "$bin"}phase_install() {+ stage_bundle_inputsrequire_manifest- local old_tag old_version old_commit old_identity old_zip+ local old_tag old_version old_commit old_identity old_team old_zipold_tag="$(manifest_side old tag)"; old_version="$(manifest_side old version)"old_commit="$(manifest_side old commit)"; old_identity="$(manifest_side old identity)"+ old_team="$(manifest_side old teamId)"old_zip="$(manifest_side old artifact)"- step "installing OLD bundle $old_tag ($old_version, team $old_identity)"+ step "installing OLD bundle $old_tag ($old_version, identity $old_identity, team $old_team)"- # Artifact bytes: the parent resolver verified the remote sha256; we+ # Artifact bytes: the common resolver verified the remote sha256; we# re-verify the local file so the unzipped bundle provably IS the release.local gotgot="$(shasum -a 256 "$old_zip" | awk '{print $1}')"local want- want="$(node -e 'const m=require(process.argv[1]); console.log(m.old.artifact.sha256.toLowerCase())' "$MANIFEST")"+ want="$("$NODE_BIN" -e 'const m=require(process.argv[1]); console.log(m.old.artifact.sha256.toLowerCase())' "$MANIFEST")"[ "$got" = "$want" ] || fail "OLD zip sha256 $got != manifest $want"ok "OLD zip sha256 verified"@@ -140,20 +189,35 @@ phase_install() {local foundfound="$(find "$WORK_ROOT/install-old" -maxdepth 2 -name '*.app' -type d | head -1)"[ -n "$found" ] || fail "no .app inside the OLD release zip"- mv "$found" "$OLD_APP"+ local old_app="$WORK_ROOT/apps/Hermes.app"+ mv "$found" "$old_app"# curl/unzip'd files carry no quarantine attr, but belt and braces.- xattr -dr com.apple.quarantine "$OLD_APP" 2>/dev/null || true- [ -x "$OLD_APP_BIN" ] || fail "no executable at $OLD_APP_BIN"- ok "OLD bundle installed at $OLD_APP"+ xattr -dr com.apple.quarantine "$old_app" 2>/dev/null || true+ local old_app_bin+ old_app_bin="$(derive_app_bin "$old_app")"+ ok "OLD bundle installed at $old_app (executable: $(basename "$old_app_bin"))"- node "$ASSETS/mac-bundled-verify.mjs" verify-app \- --app "$OLD_APP" \+ "$NODE_BIN" "$ASSETS/mac-bundled-verify.mjs" verify-app \+ --app "$old_app" \--expect-version "$old_version" \--expect-commit "$old_commit" \--expect-tag "$old_tag" \--expect-identity "$old_identity" \+ --expect-team "$old_team" \+ --expect-arch "$ARCH" \--out "$LOG_DIR/old-bundle-verify.json" 2>&1 | ts_prefix | tee "$LOG_DIR/old-bundle-verify.log"- ok "OLD bundle: codesign, team, version and stamp all match the manifest"+ ok "OLD bundle: codesign, identity, team, version, arch and stamp all match the manifest"++ # Persist the installed paths for the update phase: the executable name+ # comes from the bundle's own Info.plist and both phases must agree.+ "$NODE_BIN" -e '+ const fs = require("node:fs")+ fs.writeFileSync(process.argv[1], JSON.stringify({+ app: process.argv[2], bin: process.argv[3], arch: process.env.E2E_ARCH,+ recordedAt: new Date().toISOString(),+ }, null, 2) + "\n")+ ' "$INSTALL_RECEIPT" "$old_app" "$old_app_bin"+ ok "install receipt persisted at $INSTALL_RECEIPT"# Isolated user state: a private HOME/HERMES_HOME plus one profile marker# file the update must leave untouched.@@ -174,9 +238,18 @@ ensure_playwright() {phase_update() {require_manifest- local new_tag new_version new_commit new_identity new_zip+ [ -f "$INSTALL_RECEIPT" ] || fail "no install receipt at $INSTALL_RECEIPT — run the install phase first"+ local old_app old_app_bin+ old_app="$("$NODE_BIN" -e 'console.log(require(process.argv[1]).app)' "$INSTALL_RECEIPT")"+ old_app_bin="$("$NODE_BIN" -e 'console.log(require(process.argv[1]).bin)' "$INSTALL_RECEIPT")"+ [ -d "$old_app" ] || fail "installed app $old_app (from the install receipt) is gone"+ [ -x "$old_app_bin" ] || fail "installed executable $old_app_bin (from the install receipt) is gone"+ ok "update phase using the receipt's installed executable: $old_app_bin"++ local new_tag new_version new_commit new_identity new_team new_zipnew_tag="$(manifest_side new tag)"; new_version="$(manifest_side new version)"new_commit="$(manifest_side new commit)"; new_identity="$(manifest_side new identity)"+ new_team="$(manifest_side new teamId)"new_zip="$(manifest_side new artifact)"# Snapshot + seed plugin fixtures BEFORE anything moves (shared owner).@@ -194,49 +267,54 @@ phase_update() {step "building the loopback feed from the REAL NEW signed zip"local got wantgot="$(shasum -a 256 "$new_zip" | awk '{print $1}')"- want="$(node -e 'const m=require(process.argv[1]); console.log(m.new.artifact.sha256.toLowerCase())' "$MANIFEST")"+ want="$("$NODE_BIN" -e 'const m=require(process.argv[1]); console.log(m.new.artifact.sha256.toLowerCase())' "$MANIFEST")"[ "$got" = "$want" ] || fail "NEW zip sha256 $got != manifest $want"rm -rf "$FEED_DIR"- node "$ASSETS/mac-bundled-feed.mjs" \+ "$NODE_BIN" "$ASSETS/mac-bundled-feed.mjs" \--out "$FEED_DIR" --zip "$new_zip" \--version "$new_version" --tag "$new_tag" --arch "$ARCH" \2>&1 | ts_prefix | tee "$LOG_DIR/feed-build.json"ok "feed materialized at $FEED_DIR"- local serve_pid- node "$ASSETS/mac-bundled-serve.mjs" --dir "$FEED_DIR" --port "$FEED_PORT" \- --log "$LOG_DIR/feed-requests.jsonl" > "$LOG_DIR/feed-server.log" 2>&1 &- serve_pid=$!- trap 'mock_stop 2>/dev/null || true; kill "$serve_pid" 2>/dev/null || true' EXIT- for _ in 1 2 3 4 5 6 7 8 9 10; do- curl -fsS "$FEED_URL/__healthz" >/dev/null 2>&1 && break- sleep 0.3+ "$NODE_BIN" "$ASSETS/mac-bundled-serve.mjs" --dir "$FEED_DIR" --port 0 \+ --log "$LOG_DIR/feed-requests.jsonl" --ready "$FEED_READY" \+ > "$LOG_DIR/feed-server.log" 2>&1 &+ SERVE_PID=$!+ for _ in $(seq 1 50); do+ [ -f "$FEED_READY" ] && break+ kill -0 "$SERVE_PID" 2>/dev/null || { cat "$LOG_DIR/feed-server.log" | ts_prefix; fail "feed server exited before listening"; }+ sleep 0.2done- curl -fsS "$FEED_URL/__healthz" >/dev/null 2>&1 || fail "loopback feed server did not come up on $FEED_URL"- ok "loopback feed serving on $FEED_URL"+ [ -f "$FEED_READY" ] || fail "feed server never reported its port ($FEED_READY)"+ local feed_port feed_url+ feed_port="$("$NODE_BIN" -e 'console.log(require(process.argv[1]).port)' "$FEED_READY")"+ feed_url="http://127.0.0.1:$feed_port"+ curl -fsS "$feed_url/__healthz" >/dev/null 2>&1 || fail "loopback feed did not answer on $feed_url"+ ok "loopback feed serving on $feed_url (ephemeral port $feed_port)"# ── configure the app like a user: config.yaml ────────────────────────# The production resolution order is config updates.desktop_feed_base_url# first (main.ts resolveDesktopFeedBaseUrl). Loopback HTTP is the one# non-HTTPS override the production client accepts (mac-client.ts).step "configuring updates.desktop_feed_base_url in the isolated config"+ local config_feed_line=" desktop_feed_base_url: $feed_url"grep -q '^updates:' "$HERMES_HOME/config.yaml" 2>/dev/null || printf '\nupdates:\n' >> "$HERMES_HOME/config.yaml"- grep -qF "$CONFIG_FEED_LINE" "$HERMES_HOME/config.yaml" || printf '%s\n' "$CONFIG_FEED_LINE" >> "$HERMES_HOME/config.yaml"+ grep -qF "$config_feed_line" "$HERMES_HOME/config.yaml" || printf '%s\n' "$config_feed_line" >> "$HERMES_HOME/config.yaml"cat "$HERMES_HOME/config.yaml" | ts_prefix | tee "$LOG_DIR/config.yaml"- ok "feed base URL configured: $FEED_URL"+ ok "feed base URL configured: $feed_url"# ── the external relaunch watcher ─────────────────────────────────────# Started by THIS shell, detached from Playwright and from the app. It# owns the automatic-relaunch proof end to end.step "starting the external relaunch watcher"- node "$ASSETS/mac-bundled-relaunch-watch.cjs" \- --app-bin "$OLD_APP_BIN" \+ "$NODE_BIN" "$ASSETS/mac-bundled-relaunch-watch.cjs" \+ --app-bin "$old_app_bin" \--out "$LOG_DIR/relaunch-proof.json" \--old-pid-file "$LOG_DIR/old-pid" \--new-pid-file "$LOG_DIR/new-pid" \--timeout-ms "$UPDATE_WATCH_TIMEOUT_MS" > "$LOG_DIR/relaunch-watch.log" 2>&1 &- local watcher_pid=$!- ok "watcher running (pid $watcher_pid)"+ WATCHER_PID=$!+ ok "watcher running (pid $WATCHER_PID)"# ── the real user trigger ─────────────────────────────────────────────step "launching the OLD app and clicking About -> Update now"@@ -248,48 +326,51 @@ phase_update() {"$pw_dir/"local rc=0(cd "$pw_dir" && node mac-bundled-update-driver.mjs \- --app-bin "$OLD_APP_BIN" \+ --app-bin "$old_app_bin" \--shots "$LOG_DIR/shots" \--close-timeout-ms 420000 2>&1 | ts_prefix | tee "$LOG_DIR/app-update.log") || rc=$?log_group "in-app update (Playwright) transcript" "$LOG_DIR/app-update.log"[ "$rc" -eq 0 ] || fail "in-app update driver exited $rc; transcript above"step "waiting for Squirrel.Mac to swap and relaunch (watcher owns the proof)"- if ! wait "$watcher_pid"; then+ if ! wait "$WATCHER_PID"; thencat "$LOG_DIR/relaunch-proof.json" 2>/dev/null | ts_prefix || truefail "relaunch watcher did not observe the automatic relaunch within ${UPDATE_WATCH_TIMEOUT_MS}ms"fi+ WATCHER_PID=""log_group "relaunch watcher record" "$LOG_DIR/relaunch-proof.json"local old_pid new_pidold_pid="$(cat "$LOG_DIR/old-pid")"new_pid="$(cat "$LOG_DIR/new-pid")"[ "$old_pid" != "$new_pid" ] || fail "relaunch proof shows the SAME pid ($new_pid); no replacement happened"- node -e '+ "$NODE_BIN" -e 'const r = require(process.argv[1])if (r.newBirth && r.oldBirth && r.newBirth === r.oldBirth) process.exit(1)' "$LOG_DIR/relaunch-proof.json" || fail "old and new processes report the same birth time"# The relaunch must be at the SAME installed path: Squirrel replaces the# bundle in place; a different path would mean something else started it.- node -e '+ "$NODE_BIN" -e 'const r = require(process.argv[1])- if (!r.oldPid || !r.newPid || !r.oldExitedAt || !r.newSeenAt) process.exit(1)- ' "$LOG_DIR/relaunch-proof.json" || fail "incomplete relaunch proof record"- ok "automatic relaunch: old pid $old_pid exited, new pid $new_pid at $OLD_APP_BIN (no driver launch)"+ if (!r.oldPid || !r.newPid || !r.oldExitedAt || !r.newSeenAt || r.appBin !== process.argv[2]) process.exit(1)+ ' "$LOG_DIR/relaunch-proof.json" "$old_app_bin" || fail "incomplete relaunch proof record"+ ok "automatic relaunch: old pid $old_pid exited, new pid $new_pid at $old_app_bin (no driver launch)"# ── the NEW bundle in place ───────────────────────────────────────────step "verifying the NEW bundle Squirrel installed"- node "$ASSETS/mac-bundled-verify.mjs" verify-app \- --app "$OLD_APP" \+ "$NODE_BIN" "$ASSETS/mac-bundled-verify.mjs" verify-app \+ --app "$old_app" \--expect-version "$new_version" \--expect-commit "$new_commit" \--expect-tag "$new_tag" \--expect-identity "$new_identity" \+ --expect-team "$new_team" \+ --expect-arch "$ARCH" \--out "$LOG_DIR/new-bundle-verify.json" 2>&1 | ts_prefix | tee "$LOG_DIR/new-bundle-verify.log"- ok "NEW bundle: codesign, team ($new_identity), version $new_version, stamp commit $new_commit"+ ok "NEW bundle: codesign, identity ($new_identity), team ($new_team), version $new_version, stamp commit $new_commit"# ── old processes are gone, new backend healthy ───────────────────────- if pgrep -f "$OLD_APP_BIN" | grep -qvw "$new_pid"; then+ if pgrep -f "$old_app_bin" | grep -qvw "$new_pid"; thenfail "old bundle processes still running after the update"fiok "no stale bundle processes"@@ -325,7 +406,7 @@ phase_update() {|| fail "isolated user-state marker did not survive the update"ok "isolated user state survived"- step "PASS: packaged $old_tag -> $new_version via the real About -> Update now route"+ step "PASS: packaged $new_tag -> $new_version via the real About -> Update now route"}case "$PHASE" in