Skip to content

fix(installer): bundle uv binary for mac-arm64 - #967

Merged
itomek merged 17 commits into
mainfrom
claude/priceless-dubinsky-2a062c
May 6, 2026
Merged

itomek merged 17 commits into
mainfrom
claude/priceless-dubinsky-2a062c

Conversation

@itomek

@itomek itomek commented May 6, 2026 •

Copy link
Copy Markdown
Collaborator

Before: installing the macOS DMG on a clean Apple-Silicon Mac with no system uv on PATH hard-failed during ensure-uv — bundledUvPlatformKey() claimed mac-arm64 support, but no CI step ever fetched the binary. First-launch error: "No bundled uv available for darwin-arm64 and no system uv found". After: the macOS build job fetches the pinned uv v0.5.14 aarch64-apple-darwin binary, verifies its archive SHA, and places it at build/vendor/uv/mac-arm64/uv so electron-builder ships it inside Contents/Resources/vendor/uv/mac-arm64/uv. A new dmg-structural-smoke CI job mounts the built DMG, asserts the binary is present + executable + SHA-pinned + actually runs (uv --version), and is wired into the build-complete gate so future drift fails at smoke time, not on a user's first launch.

Also bundled: the pr-review job in .github/workflows/claude.yml is temporarily disabled (if: false) because the CI bot's Anthropic API key is out of credits — auto-review will not run on this or any PR until the credit balance is restored. Tracked for re-enable separately from this fix.

Closes #941.

Test plan

  • Trigger build-installers workflow against this branch and confirm dmg-structural-smoke and build-complete are both green
  • On a clean Apple-Silicon Mac with no system uv (verify: which uv → not found): download the DMG via browser (not gh run download — browser sets the quarantine xattr that Gatekeeper checks), install, launch GAIA, confirm it reaches state: ready with no ensure-uv error and no Killed: 9 on the spawned uv child
  • Confirm ~/.gaia/bin/uv --version works after install
  • Test on macOS Sequoia (15.x) — Sequoia tightened CS checks for child processes spawned by hardened-runtime apps

The macOS DMG shipped a runtime contract it did not honour:
bundledUvPlatformKey() claims mac-arm64 support but no CI step ever
fetched a mac-arm64 uv binary, so first launch on a clean Mac with no
system uv on PATH hard-failed during ensure-uv. Mirror the existing
linux-x64 fetch step + AppImage smoke pattern (#782/#849) for macOS:

- Add `Fetch uv binary (macOS)` workflow step that downloads uv
  v0.5.14 for aarch64-apple-darwin, verifies the archive against the
  upstream .sha256 sidecar, and stages the extracted binary under
  build/vendor/uv/mac-arm64/ for electron-builder's extraResources to
  ship inside the .app at Contents/Resources/vendor/uv/mac-arm64/uv.
- Register the extracted-binary SHA256 in BUNDLED_UV_SHA256 so the
  runtime ensureUv() check accepts the packaged binary.
- Add a dmg-structural-smoke job + tests/electron/dmg-smoke.test.mjs
  that mounts the DMG, verifies the bundled uv (existence, mode,
  SHA-pin) and runs `uv --version`. Wire it into the build-complete
  release-readiness gate so a smoke regression actually blocks ship.
- Extract a shared tests/electron/_helpers/installer-smoke.mjs so the
  AppImage and DMG smoke tests use one source of truth for the
  vendor/uv path layout and the SHA-pin parser. Refactor
  appimage-smoke.test.mjs onto the helper.
- Extend the workflow's pull_request paths filter to tests/electron/**
  so smoke regressions in the test layer itself surface at PR time.

win-x64 bundling is intentionally deferred to a follow-up that ships
the workflow step, the NSIS structural smoke job, and the SHA constant
together — shipping a SHA without an automated verifier was the #849
anti-pattern this PR is designed to repair.
@itomek
itomek requested a review from kovtcharov-amd as a code owner May 6, 2026 16:10
@github-actions github-actions Bot added devops DevOps/infrastructure changes tests Test changes labels May 6, 2026
itomek added 4 commits May 6, 2026 12:19
…me and version sync

SettingsModal.tsx was renamed to SettingsPage.tsx (full-page view, not a modal
overlay) but test_electron_chat_app.js still referenced the old name, causing
ENOENT failures. Also syncs package.json version to 0.17.6 to match version.py.
electron-builder code-signs bundled binaries during .app packaging, changing
their SHA256. The previous pin was the raw extracted-from-tarball hash; this
updates it to the hash of the signed binary that ensureUv() sees at runtime.
Bumping package.json to 0.17.6 broke the macOS installer: resolveBackendVersion()
reads package.json to construct 'amd-gaia[ui]==<version>' for pip, and 0.17.6 does
not exist on PyPI yet (latest is 0.17.5). Reverted to 0.17.5.

version.py is intentionally bumped ahead of PyPI during development; package.json
tracks the last published version. The test now asserts package.json has valid
semver and is not ahead of version.py, instead of requiring exact equality.
kovtcharov-amd
kovtcharov-amd previously approved these changes May 6, 2026
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes a real first-launch hard-fail on clean Apple-Silicon Macs (bundledUvPlatformKey() claimed mac-arm64 support but no CI step ever shipped the binary). The fix is well-scoped: fetch + verify the pinned uv tarball in the build job, pin the post-codesigned binary digest in BUNDLED_UV_SHA256, and add a dmg-structural-smoke job wired into build-complete so the same drift can never silently re-ship. The shared tests/electron/_helpers/installer-smoke.mjs extraction is the standout — it eliminates the linux/mac duplication before it could rot, and pre-empts the same divergence for the NSIS smoke that the comments correctly defer.

Issues

🟢 Minor

Scope creep: claude.yml if: false is unrelated to #941 (.github/workflows/claude.yml:60)

The PR description and title scope to "bundle uv binary for mac-arm64." Disabling pr-review (commit a013e384, "credit balance exhausted") is a separate operational concern and would have been cleaner as its own PR. Not blocking — the change is small and obvious from git log — but worth flagging so future archeology of why pr-review was disabled doesn't blame the uv fix.

Temp workdir is never cleaned up (tests/electron/dmg-smoke.test.mjs:491)

const workdir = fs.mkdtempSync(path.join(os.tmpdir(), "gaia-dmg-"));

workdir is created but never fs.rmSync(workdir, { recursive: true }). CI runners are ephemeral so this is a no-op in practice, but local re-runs accumulate gaia-dmg-* directories under $TMPDIR. Could be added to the finally block right after the hdiutil detach, with the same non-throwing error-log pattern used for detach.

pkgAhead semver comparison silently passes prerelease tags (tests/electron/test_electron_chat_installer.js:663-668)

const pkgParts = pkg.version.split('.').map(Number);
const pkgAhead = pkgParts.some((n, i) =>
  n > (pyParts[i] ?? 0) && pkgParts.slice(0, i).every((m, j) => m === (pyParts[j] ?? 0))
);

"0.18.0-beta.1".split('.').map(Number) → [0, 18, NaN, NaN, 1]. NaN > anything === false, so a prerelease bump in package.json ahead of version.py would slip past unnoticed. The immediate fix (relax the strict equality so 0.17.5 → 0.17.6 dev work doesn't fail CI) is right; the comparison itself is just imprecise. Acceptable for now, but if this file ever needs to handle prerelease bumps, prefer a real semver lib (e.g. semver.gt(pkg.version, match[1])).

backendInstallerPath doesn't decodeURIComponent (tests/electron/_helpers/installer-smoke.mjs:300-310)

new URL(testFileUrl).pathname returns percent-encoded segments (e.g. %20 for spaces). On a runner workspace path with spaces — unlikely on ubuntu-latest / macos-latest, but possible if someone runs locally on a Mac with a space in their home dir name — path.resolve on the encoded string silently produces a broken path that fails on fs.readFileSync with a confusing ENOENT. One-line fix:

export function backendInstallerPath(testFileUrl) {
  return path.resolve(
    path.dirname(decodeURIComponent(new URL(testFileUrl).pathname)),
    "..",
    "..",
    "src",
    "gaia",
    "apps",
    "webui",
    "services",
    "backend-installer.cjs",
  );
}

Strengths

  • Helper extraction is the right call, done at the right time (tests/electron/_helpers/installer-smoke.mjs). Three smoke tests (linux, mac, future NSIS) sharing one source of truth for UV_RESOURCE_SUBPATH, the BUNDLED_UV_SHA256 regex, and assertUvBinary. The JSDoc and the if electron-builder.yml changes the to: path, every smoke test breaks here with the same actionable diff comment are exactly the kind of forward-pointer that prevents future drift.
  • Defense in depth on the SHA: workflow step verifies archive provenance against upstream's published digest; BUNDLED_UV_SHA256["mac-arm64"] verifies the post-codesigned packaged binary; runtime ensureUv() re-hashes on copy. The comment at backend-installer.cjs:84-87 explicitly calls out why these are different digests — that note will save the next maintainer real time.
  • Cleanup discipline in dmg-smoke.test.mjs: the comment block at lines ~441-449 about node:test scheduling vs. live mounts is genuinely instructive, and the try/finally with non-throwing error logging on hdiutil detach -force correctly avoids masking earlier assertion failures with a cleanup error. Good awareness of the "Resource busy on next CI job" failure mode too.
  • build-complete wiring: smoke jobs that don't gate the release verdict are theatre; this one is added to both needs: and the per-result loop, with the error message generalised from "AppImage smoke" to "Installer smoke" so the failure surface is honest.
  • Path filter widening with justification (build-installers.yml:9-13): the comment explains why tests/electron/** supersedes tests/electron/fixtures/**, so a future trim doesn't silently re-introduce the trigger gap.

Verdict

Approve. Issues are all 🟢 nits — none blocks merge. The fix is targeted at the actual P0 install-time failure, the new smoke job is correctly wired to gate releases, and the helper-module extraction makes this PR a net architectural improvement, not just a hotfix. Pre-existing reviewer approval (kovtcharov-amd) and the explicit on-clean-Mac validation in the test plan covers the empirical leg.

…n up DMG workdir

backendInstallerPath() used new URL().pathname raw, which percent-encodes
path segments on hosts where the workspace contains spaces (e.g. a local
Mac with a space in the home directory name). fs.readFileSync would silently
fail with ENOENT on the encoded path. Wrapping in decodeURIComponent() is
the standard fix; fileURLToPath() would also work but adds an import.

dmg-smoke workdir (gaia-dmg-*) was never deleted, accumulating stale
directories on local re-runs. Added a non-throwing fs.rmSync in the existing
finally block after hdiutil detach, matching the error-logging pattern used
for the detach step so workdir cleanup never masks a test assertion failure.
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes a real first-launch failure on clean Apple-Silicon Macs by (a) actually fetching the uv binary in the macOS build job, (b) pinning the post-codesign SHA in BUNDLED_UV_SHA256["mac-arm64"], and (c) wiring a new dmg-structural-smoke job — that mounts the DMG and runs uv --version against the bundled binary — into the build-complete gate. The shared tests/electron/_helpers/installer-smoke.mjs helper is the right call: AppImage and DMG smokes now share a single source of truth for the layout/SHA assertions, and a future NSIS smoke can plug in the same way. Code is well-scoped, well-commented (the rationale notes about post-codesign digest, the node:test scheduling vs. live mount footgun, and the transitive mode-bit check are exactly the kind of "why" comments that pay off later), and CI gating is wired correctly.

Issues

🟢 Minor

Prefer fileURLToPath over manual decodeURIComponent(new URL(...).pathname) (tests/electron/_helpers/installer-smoke.mjs:116)

node:url ships a canonical file: URL → path converter that handles percent-encoding and the /C:/... Windows quirk. The current form will need another fix-up commit when NSIS structural smoke lands.

import assert from "node:assert/strict";
import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";

…and at backendInstallerPath:

export function backendInstallerPath(testFileUrl) {
  return path.resolve(
    path.dirname(fileURLToPath(testFileUrl)),
    "..",
    "..",
    "src",
    "gaia",
    "apps",
    "webui",
    "services",
    "backend-installer.cjs",
  );
}

Unused s (dotall) flag on parseBundledUvSha regex (tests/electron/_helpers/installer-smoke.mjs:246)

The pattern relies on \s* and [^}]*? to span lines — neither uses ., so the dotall flag is a no-op. Drop it to avoid signalling intent the regex doesn't actually have.

  const re = new RegExp(
    `BUNDLED_UV_SHA256\\s*=\\s*\\{[^}]*?"${escapedKey}"\\s*:\\s*"([0-9a-f]{64})"`,
  );

claude.yml if: false loses the "why" (.github/workflows/claude.yml:60)

A bare if: false will read as dead config to the next maintainer. The original gating expression is gone from history-at-a-glance, and there's no inline note that this is temporary (credit-balance exhaustion per a013e384). One-line comment would prevent a future "let me clean this up" PR from re-enabling it without context.

  pr-review:
    # Temporarily disabled — Anthropic credit balance exhausted (see commit a013e384).
    # To re-enable: restore the original `repository / event_name / draft / label` gate.
    if: false

Version-sync test silently passes for pre-release suffixes (tests/electron/test_electron_chat_installer.js:660-672)

pkg.version.split('.').map(Number) on something like "0.17.5-rc.1" produces [0, 17, NaN, 1], and NaN > anything === false, so a pre-release package.json would be reported as "not ahead" even when it semver-wise is. Probably out of scope for this PR (the regex anchors at start, and current versions are clean), but worth noting on the tracker since this test now has explicit pre-release-tolerance semantics. Comment-only — no action requested here.

T3 in appimage-smoke is partially redundant with T3b post-refactor (tests/electron/appimage-smoke.test.mjs:147-156)

assertUvBinary in the helper already covers existence + executable-bit + SHA, so the standalone T3 (existence + exec-bit) duplicates the first half of T3b. The PR comment notes this is preserved "for output stability with prior CI logs," which is a defensible choice — flagging only because a future reader will wonder why T3 isn't a one-liner assert.ok(fs.existsSync(uvPath)) plus a comment pointing at T3b. Optional: collapse T3 to existence-only, since the mode-bit assertion is fully owned by assertUvBinary now.

Strengths

  • Failure mode fully covered, end-to-end. The DMG smoke goes beyond pin-check theatre by mounting the DMG and actually invoking uv --version against the bundled binary — that catches Gatekeeper/quarantine and codesign drift that pure SHA checks miss. The accompanying note on transitive mode-bit validation via execFileSync-EACCES is a good example of leveraging existing primitives instead of adding redundant checks.
  • CI wiring is correct. dmg-structural-smoke is added to build-complete needs: AND to the for r in ... loop AND to the result-printing block — the comment on the new job explicitly calls out that the wiring must be present, and it is. This is the kind of three-place change that's easy to miss.
  • Refactor reduces drift risk for the next installer. Extracting _helpers/installer-smoke.mjs ahead of the win-x64 follow-up means the NSIS smoke gets assertUvBinary/bundledUvPath/parseBundledUvSha for free, with the platform-key abstraction already in place.
  • Excellent in-code rationale. The post-codesign digest comment in backend-installer.cjs:79, the node:test-vs-live-mount footgun in dmg-smoke.test.mjs:35, and the trigger-paths comment in build-installers.yml:10 are all the right kind of "why" — future maintainers will thank you.

Verdict

Approve with suggestions. No blocking issues. The four 🟢 minors above are polish items the author can apply (or punt to a follow-up); none should hold the v0.17.6 release. Ship it.

…gsPage

main removed the danger-zone section class and .danger-zone CSS rule between
the branch point and now; our branch never touched those files, so the merge
commit follows main's version. The danger-warning and danger-divider pieces
are still present in both files and cover the intent of the test.
…ml disable

installer-smoke.mjs:
- Replace decodeURIComponent(new URL().pathname) with fileURLToPath() from
  node:url — the canonical converter that also handles the /C:/... Windows
  quirk; avoids another fix-up commit when NSIS smoke lands
- Drop the 's' (dotall) flag from parseBundledUvSha regex: [^}]*? spans
  newlines natively (char classes match \n without dotall), so the flag
  was a no-op signalling false intent; update the JSDoc accordingly

claude.yml:
- Add two-line comment on the 'if: false' disable so future maintainers
  know it is temporary (credit balance exhaustion) and where to find the
  original gating expression to restore
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Solid, well-scoped CI/installer fix for issue #941. The PR mirrors the existing Linux uv-fetch pattern for macOS, extracts the structural-smoke assertions into a shared helper module so AppImage and DMG stay in lockstep, and wires dmg-structural-smoke into the build-complete gate so future drift fails at smoke time rather than on a user's first launch. Comments are unusually clear — every non-obvious choice (post-codesign SHA, [^}]*? instead of dotall, async-test wrapping for hdiutil mount lifetime) is justified inline. The single most important thing: the mac-arm64 SHA pin is the post-codesign digest, which the PR author has correctly documented but is easy for a future maintainer to bump incorrectly — see suggestion below.

Issues

🟢 Minor — make the post-codesign-vs-archive SHA distinction harder to miss (src/gaia/apps/webui/services/backend-installer.cjs:174)

The comment explains that BUNDLED_UV_SHA256["mac-arm64"] is the post-signing digest while linux-x64 is the raw archive digest — but a maintainer skim-reading on a SHA-bump PR could easily miss it. Consider promoting the per-key origin into the table so it survives future edits:

// Currently pinned: uv v0.5.14 linux-x64, mac-arm64.
// (win-x64 deferred to a follow-up issue — its SHA must ship together with an
// NSIS structural-smoke verifier, not on its own; see the #849 lesson.)
//
// IMPORTANT: per-platform SHA origin differs:
//   - linux-x64:  raw extracted-from-tarball digest (no post-build modification).
//   - mac-arm64:  POST-CODESIGN digest. electron-builder code-signs the bundled
//                 uv during packaging, so this hash matches what ensureUv() sees
//                 at runtime, NOT the upstream tarball. Bumping this pin means
//                 running the CI build, then copying the SHA from the
//                 dmg-structural-smoke failure message — never from `shasum`
//                 against the freshly downloaded tarball.
const BUNDLED_UV_VERSION = "0.5.14";
const BUNDLED_UV_SHA256 = {
  "linux-x64": "0e05d828b5708e8a927724124db3746396afddad6273c47283d7c562dc795bd6",
  "mac-arm64": "6099aa8cd701f0c81227ee30c304777ce151e4d47c53a75ce53cd2243448d8c8",
};

🟢 Minor — dmg-structural-smoke job is missing permissions: block (.github/workflows/build-installers.yml:71)

The new job inherits the workflow-level permissions: (which grants contents: write for release upload). The mirror job appimage-structural-smoke doesn't set per-job permissions either, so this is consistent with prior art — but per least-privilege hygiene called out in the workflow header (line 16-19), a smoke-only job that just downloads an artifact and runs node --test should declare permissions: { contents: read } explicitly. Comment-only — no blocking change needed; flagging because the workflow already advertises a least-privilege posture.

🟢 Minor — version-sync test silently passes for pre-release tags (tests/electron/test_electron_chat_installer.js:653-659)

pkg.version.split('.').map(Number) produces NaN at index 2 for any pre-release suffix (e.g. 0.17.5-rc1 → [0, 17, NaN]). Since NaN > anything is always false, pkgAhead becomes false and the assertion silently passes regardless of the actual version relationship. This is acceptable as-is — pre-release pkg versions aren't a documented case for this repo — but worth a one-line guard if you want the test to be future-proof:

      // package.json tracks the last *published* PyPI version; version.py is
      // bumped ahead of PyPI during development. They must match at release
      // time but may legitimately differ pre-release. Assert package.json has a
      // valid semver and is not AHEAD of version.py (that would be a bug).
      expect(pkg.version).toMatch(/^\d+\.\d+\.\d+$/);
      expect(match[1]).toMatch(/^\d+\.\d+\.\d+$/);
      const pkgParts = pkg.version.split('.').map(Number);
      const pyParts = match[1].split('.').map(Number);
      const pkgAhead = pkgParts.some((n, i) =>
        n > (pyParts[i] ?? 0) && pkgParts.slice(0, i).every((m, j) => m === (pyParts[j] ?? 0))
      );
      expect(pkgAhead).toBe(false);

The added $ anchors and the symmetric assertion on version.py make the NaN-silently-passes hole impossible to hit accidentally.

🟢 Minor — 5×100 ms VFS-readdir loop is empirically tight (tests/electron/dmg-smoke.test.mjs:528-535)

500 ms total has worked in your testing on macos-latest, but loaded GitHub-hosted runners under spot pressure can spike well above that. If dmg-structural-smoke ever flakes with no .app bundle found inside DMG, the first lever is to bump this to 10×200ms (2 s total). Consider doing it now so you don't get paged by a flake later — non-blocking.

Strengths

  • Shared helper module is exactly the right refactor. tests/electron/_helpers/installer-smoke.mjs collapses three duplicated concerns (path layout, SHA parsing, exec/SHA assertion) into one source of truth, and the contract is small enough that a future NSIS smoke test can be added in <30 lines. The UV_RESOURCE_SUBPATH constant explicitly anchors to electron-builder.yml's extraResources.to — that's the kind of cross-file invariant comment that pays for itself the first time someone refactors the build config.
  • The async-test wrap around the hdiutil mount lifetime (line 446-451) is the right call and the comment block is excellent. The node:test scheduling footgun (top-level test() registers synchronously but bodies run after module load) is exactly the kind of thing that bites a reviewer who tries to "simplify" the structure later — the inline explanation of why subtests-via-t.test() are required will save someone an hour of debugging.
  • Failure-mode coverage is comprehensive without being theatrical. AC3/T5c: uv --version runs transitively validates DMG mode-bit preservation, code-signing validity, and Gatekeeper-quarantine state in one call — pure existence/SHA checks would miss all three. The cleanup pattern (hdiutil detach -force in finally, errors logged not thrown) correctly prioritises preserving the original assertion failure over surfacing detach noise.
  • Wiring dmg-structural-smoke into build-complete's needs: (line 1049) is the load-bearing piece that turns this from "we have a smoke test" into "drift can't ship" — easy to forget on a smoke-test PR, and the unified failure message in the loop body keeps the CI log readable.

Verdict

Approve with optional suggestions. No blockers; all four items above are minor polish. Once dmg-structural-smoke goes green on this branch (test plan item 1) and a clean Apple Silicon Mac confirms state: ready without the ensure-uv hard-fail (item 2), this is good to merge. The Anthropic-credit-driven claude.yml disable is documented and out of scope here.

…, VFS retry

backend-installer.cjs: expand the BUNDLED_UV_SHA256 comment block to make the
per-platform SHA origin impossible to miss on a bump PR. linux-x64 is the raw
tarball-extracted digest; mac-arm64 is the POST-CODESIGN digest — bumping it
requires reading the actual value from the dmg-structural-smoke failure, not
running shasum against the downloaded tarball.

build-installers.yml: add permissions: contents: read to dmg-structural-smoke;
the job only downloads an artifact and runs node --test, so write access
inherited from workflow-level was broader than needed.

test_electron_chat_installer.js: add end-anchor to semver regex (^\d+.\d+.\d+$)
and assert version.py also matches clean semver, closing the NaN-silently-passes
hole for pre-release suffixes.

dmg-smoke.test.mjs: bump VFS-readdir retry from 5x100ms to 10x200ms (2s total)
to avoid flakes on loaded GitHub-hosted runners under spot pressure.
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Solid, well-targeted fix for a real first-launch regression on Apple Silicon (the bundled-uv platform key was claimed but never shipped). The CI changes mirror the existing AppImage smoke pattern faithfully, and the extraction into tests/electron/_helpers/installer-smoke.mjs is the right call — it sets up a future NSIS smoke job to drop in cleanly. The most important thing the author should be aware of: the mac-arm64 SHA pin is documented as a post-codesign digest, which is unusual and creates a bootstrap dependency on CI to seed the value — the documentation in backend-installer.cjs handles this clearly, but it’s worth a maintainer eye on the workflow.

Issues Found

🟢 Minor — stale retry-loop comment (tests/electron/dmg-smoke.test.mjs:105)

The comment says "5×100ms is empirically enough on macos-latest", but the loop below runs 10 iterations at 200 ms each (max 2 s). Either the comment was written first and the values bumped during testing, or vice versa. Cheap fix, prevents future confusion when someone bumps timing again:

      // ── Locate the .app bundle inside the mounted DMG ───────────────
      // hdiutil attach returns synchronously when the volume is
      // registered, but the kernel VFS layer can lag 1–2 ticks before
      // readdir sees the contents. Without this loop, an unguarded
      // path.join(mountpoint, undefined, …) throws an unactionable
      // TypeError. 10×200ms (≤2s) is empirically enough on macos-latest.

🟢 Minor — assertUvBinary re-does work AC4/T3 already covers (tests/electron/appimage-smoke.test.mjs:128-148)

The new helper performs existence + exec-bit + SHA in one shot, but the AppImage test still has a separate AC4/T3 block that hand-checks existence + exec, and then T3b calls assertUvBinary which repeats those checks before the SHA assertion. The diff comment ("Two named test blocks preserved for output stability with prior CI logs") explains the intent — fine to keep, just flagging because if a reader reaches for the helper expecting it to be SHA-only, they’ll find it isn’t. Consider either splitting the helper into assertUvPresentAndExecutable + assertUvSha256, or letting T3 call the existence/exec parts of the helper and T3b a SHA-only helper. Not blocking.

🟢 Minor — scope creep from rebase alignment (tests/electron/test_electron_chat_app.js, tests/electron/test_electron_chat_installer.js)

The SettingsModal → SettingsPage rename and the relaxed package.json ↔ version.py semver check are unrelated to bundling uv for mac-arm64 — they’re rebase-on-main alignment, not part of the stated fix. CLAUDE.md’s "scope-clean" rule says only files required for the stated task should be modified. The pragmatic counter-argument is that without these, CI would block this PR on unrelated breakage, so I’d leave them in but call out that the title fix(installer): bundle uv binary for mac-arm64 undersells what the PR touches. Either expand the description’s "Why this matters" to mention the test-realignment thread, or pull these into a separate trivial PR.

🟢 Minor — claude.yml if: false short-circuit is correct but hides intent in PR diffs

Killing the gate via if: false works, but on a later contributor reading git blame it will look like every PR auto-review is wired off. The inline comment explains it, which is good. Worth a short note in the PR body that this disables auto-review repo-wide until the credit balance is restored — right now it’s only mentioned in a commit message footer. (Optional.)

🟡 Observation — POST-CODESIGN pin needs a maintainer protocol, not just a comment (src/gaia/apps/webui/services/backend-installer.cjs:172-184)

The new comment explains the post-codesign-vs-tarball SHA distinction well, including "running the CI build, then copying the SHA from the dmg-structural-smoke failure message — never from shasum against the freshly downloaded tarball." The mechanic works but it means every uv bump on macOS requires:

  1. land a PR with the new tarball SHA in the workflow + a placeholder mac-arm64 digest,
  2. observe the dmg-smoke failure, copy the failed-actual hash,
  3. land a follow-up PR.

That’s a 2-PR loop for a single bump. Not a code defect — just flagging that this should probably be captured in docs/reference/dev.mdx or the issue #941 closer, otherwise the next maintainer to bump uv won’t find the comment until they’re mid-bump and confused. No code change needed, but worth a docs follow-up.

Strengths

  • Shared-helper extraction is exactly right. tests/electron/_helpers/installer-smoke.mjs consolidates the path layout (UV_RESOURCE_SUBPATH), SHA parsing, and assertion logic — and the comment block calling out future NSIS reuse is the kind of forward-looking signpost that prevents the next bug from re-forking the logic.
  • The async-test wrapper around hdiutil attach is a thoughtful fix for a real footgun. The comment ("Top-level test() calls register tests SYNCHRONOUSLY but the runner executes their bodies AFTER the entire module has finished loading") is exactly the kind of why future maintainers need — without it someone would refactor back to top-level test() blocks and break the mount lifecycle.
  • Build-complete gate wiring is correct. New dmg-structural-smoke is added to needs: and to the inner result loop, with the error message generalised from "AppImage smoke job failed" to "Installer smoke job failed". The comment block warning that the gate wiring is load-bearing is the right defensive posture.
  • Cleanup is robust without masking failures. hdiutil detach -force + console.error-but-don’t-throw on failure is the right shape — a failed detach won’t mask an earlier assertion failure, and -force handles Spotlight’s transient busy-mount.
  • fileURLToPath over new URL(...).pathname in the helper avoids the Windows path bug — small, correct.

Verdict

Approve with suggestions. No blockers. The single suggestion that should land is the stale retry-loop comment fix in dmg-smoke.test.mjs:105. The post-codesign pin protocol and the rebase-alignment scope expansion are worth a maintainer’s eye but don’t block merge.

@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Solid, well-scoped infrastructure fix that closes a real first-launch regression on Apple-Silicon Macs. The macOS uv-fetch step mirrors the existing Linux step exactly, the new dmg-structural-smoke job is properly wired into the build-complete gate so future drift fails at smoke time, and the shared tests/electron/_helpers/installer-smoke.mjs extraction sets up the future NSIS smoke nicely. The single most important thing the author should know: the post-codesign SHA documentation (backend-installer.cjs:82-90) is the kind of "future you will thank past you" comment that earns its keep — keep that pattern.

Issues Found

🟡 Important

Scope drift outside the stated fix(installer) title (multiple files)

Per CLAUDE.md "Scope-clean": only files required for the stated task should be modified. This PR also bundles:

  • .github/workflows/claude.yml — disables the auto-PR-review job entirely (if: false) due to credit exhaustion.
  • tests/electron/test_electron_chat_app.js — SettingsModal → SettingsPage test rename and removed role="dialog" / danger-zone assertions.
  • tests/electron/test_electron_chat_installer.js — replaces the pkg.version === version.py equality check with a semver guard.

These all look defensible (rebase polish to keep CI green, plus a credit-driven workflow disable), but they are not implied by the title and aren't called out in the PR description's "Why this matters" paragraph. Two requests:

  1. Mention the claude.yml disable in the PR body (or at least: link a tracking issue for re-enable). A reviewer scanning the body should know the auto-review will not run on this PR or future PRs until restored.
  2. Confirm there is a follow-up issue tracking restoration of the claude.yml gate, otherwise this if: false will outlive the credit issue silently.

No code change requested — flagging for the maintainer's awareness.

🟢 Minor

Redundant existence + mode check in refactored AppImage smoke (tests/electron/appimage-smoke.test.mjs:136-149)

The "AC4/T3" test now checks existsSync + executable bit, then "AC4/T3b" calls assertUvBinary which re-checks both plus SHA256. The author's comment ("Two named test blocks preserved for output stability with prior CI logs") is a fine reason to keep two test names, but the work duplicates. Consider letting the first block become a no-op shell that documents intent, e.g.:

      test("AC4/T3: bundled uv binary is present under extraResources", () => {
        // Existence + mode-bit assertions live in assertUvBinary (T3b).
        // Block kept for CI-log compatibility; see _helpers/installer-smoke.mjs.
        assert.ok(fs.existsSync(uvPath), `expected bundled uv at ${uvPath}`);
      });

Non-blocking — current code is correct.

if: always() && needs.build.result == 'success' is functionally if: needs.build.result == 'success' (.github/workflows/build-installers.yml:584)

always() only matters when an upstream needs: job fails or is cancelled and you still want to run. Combined with && needs.build.result == 'success', the always() is a no-op — the second clause already filters to the success case. The existing appimage-structural-smoke job uses the same idiom (line 544), so this is consistent — but for clarity:

    needs: build
    if: needs.build.result == 'success'

Keep the existing pattern if you'd rather stay symmetric with appimage-structural-smoke; this is purely a readability nit.

build-complete gate echoes dmg_result only after the loop variable name change (.github/workflows/build-installers.yml:1072)

The error message changed from "AppImage smoke job failed" to "Installer smoke job failed" (correct, since DMG joined the loop), and the success line changed from "AppImage smoke suite" to "installer smoke suite". Worth confirming downstream alerting (release-status dashboards, Slack notifiers) doesn't grep for the literal string AppImage smoke suite.

Workdir cleanup error path could unmount again before rmSync (tests/electron/dmg-smoke.test.mjs:586-604)

If hdiutil detach -force fails, fs.rmSync(workdir, …) will then try to remove a directory whose mnt/ subdir is still a live mount → either silently no-ops or errors. The current try/catch around rmSync swallows it, which matches the comment intent ("errors are logged but NEVER thrown"). Acceptable as-is, but a follow-up could inspect r.status and skip the rmSync when detach fails, leaving a clearer breadcrumb for whoever investigates the next runner that runs out of disk.

Strengths

  • Excellent failure-mode documentation. The // IMPORTANT: per-platform SHA origin differs block in backend-installer.cjs:82-90 and the MUST be present in build-complete needs: reminder above the new job (line 579) are exactly the kind of self-defending comments that prevent a future bump from regressing this fix. Past-incident-as-comment is a pattern the rest of the codebase should steal.
  • Correct shared-helper extraction. Pulling bundledUvPath, parseBundledUvSha, assertUvBinary, and backendInstallerPath into tests/electron/_helpers/installer-smoke.mjs makes the future Windows NSIS smoke a 30-line file. The single UV_RESOURCE_SUBPATH constant tying back to electron-builder.yml to: vendor/uv is the right level of indirection — change one place, every smoke test fails with an actionable diff.
  • Mount-lifetime correctness in dmg-smoke.test.mjs. Wrapping subtests in a single async test() so hdiutil detach only fires after assertions complete is a real node:test footgun the author called out and solved. The 10×200ms readdir loop with the explicit "kernel VFS layer can lag 1–2 ticks" justification is the right kind of pragmatic.
  • Smoke gate genuinely catches the failure mode. assertUvBinary runs assert.ok(fs.existsSync) + mode-bit + SHA256-vs-pin, and T5c actually invokes uv --version — that last one transitively validates DMG mode-bit preservation and Gatekeeper quarantine, which a pure-existence check would miss.

Verdict

Approve with suggestions — no blocking issues. The minor items above are readability nits and a request to either expand the PR body or split the claude.yml disable into its own PR. The core installer fix and CI wiring are correct and well-documented; the test-helper refactor is a net win.

kovtcharov-amd
kovtcharov-amd previously approved these changes May 6, 2026
…ssertUvBinary

assertUvBinary in the helper already re-checks existence + mode-bit + SHA256,
so the hand-rolled mode-bit assert in the standalone T3 block was redundant.
Collapse T3 to existence-only with a comment pointing to T3b; the test name is
preserved for CI-log stability per the original intent.
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes a real first-launch hard-fail on clean Apple-Silicon Macs (bundledUvPlatformKey() advertised mac-arm64 support but no CI step ever shipped the binary). The fix is well-scoped and well-documented: a new macOS uv-fetch step pinned by tarball SHA, a mac-arm64 entry in BUNDLED_UV_SHA256 (correctly noted as the post-codesign digest), and a new dmg-structural-smoke job wired into build-complete so the same drift cannot silently re-ship. The shared tests/electron/_helpers/installer-smoke.mjs extraction is the standout — it eliminates Linux↔Mac duplication before it could rot, and pre-empts the same divergence for the deferred Windows NSIS smoke. Comments throughout earn their keep — they explain why (post-codesign SHA, VFS-readdir lag, node:test scheduling, finally-detach footgun) rather than what. No security or breaking-change concerns.

Issues

🟢 Minor

workdir is leaked if hdiutil attach fails (tests/electron/dmg-smoke.test.mjs:70-91)

workdir is mkdtempSync'd at line 70, but the try { ... } finally { detach + rmSync } block only starts at line 99. If hdiutil attach fails and the assertion at line 86 throws, the finally never runs and gaia-dmg-* accumulates under $TMPDIR. Hosted CI runners are ephemeral so this doesn't bite us in CI, but local devs running this in a loop (the documented repro at lines 8–11) will leak directories. Fix is to move the temp-dir creation inside the existing try, or wrap attach itself in the try:

  test("AC3/T5: DMG structural smoke (mac-arm64)", async (t) => {
    const dmgPath = path.resolve(DMG);
    assert.ok(fs.existsSync(dmgPath), `GAIA_DMG=${dmgPath} does not exist`);

    const workdir = fs.mkdtempSync(path.join(os.tmpdir(), "gaia-dmg-"));
    const mountpoint = path.join(workdir, "mnt");
    let attached = false;
    try {
      fs.mkdirSync(mountpoint, { recursive: true });

      const attachResult = spawnSync(
        "hdiutil",
        [
          "attach",
          "-nobrowse",
          "-readonly",
          "-mountpoint",
          mountpoint,
          dmgPath,
        ],
        { stdio: ["ignore", "ignore", "pipe"], encoding: "utf8" },
      );
      assert.equal(
        attachResult.status,
        0,
        `hdiutil attach exit=${attachResult.status}\n` +
          `stderr:\n${attachResult.stderr}`,
      );
      attached = true;

…then guard the hdiutil detach in the finally with if (attached) so we don't try to detach a never-mounted path.

pkgAhead regex rejects pre-release tags (tests/electron/test_electron_chat_installer.js:653-660)

expect(pkg.version).toMatch(/^\d+\.\d+\.\d+$/);
expect(match[1]).toMatch(/^\d+\.\d+\.\d+$/);

This intentionally relaxes the strict equality (great call — the comment explains why). But the regex rejects PEP 440 pre-release suffixes (0.17.6rc1, 0.17.6.dev0, 0.17.6a1). Today both files use plain MAJOR.MINOR.PATCH, so the test passes — but the next release: v0.18.0rc1 bump will trip a guard whose comment says "may legitimately differ pre-release." Either tolerate the suffixes in the regex (e.g. /^\d+\.\d+\.\d+([a-z0-9.+\-]*)$/i and compare on the numeric prefix), or document the limitation explicitly with a TODO.

shasum -a 256 "${DEST_DIR}/uv" echo comment is misleading (.github/workflows/build-installers.yml:50-53)

# Echo the extracted-binary SHA so a maintainer bumping
# BUNDLED_UV_VERSION can cross-check BUNDLED_UV_SHA256[mac-arm64]
# without re-running T0 locally.
shasum -a 256 "${DEST_DIR}/uv"

The echoed digest is the pre-codesign SHA of the freshly extracted upstream binary, but BUNDLED_UV_SHA256["mac-arm64"] is the post-codesign digest (per the explicit comment in backend-installer.cjs:173-180). A maintainer reading "cross-check BUNDLED_UV_SHA256[mac-arm64]" against this echo will be misled — they'd see two different hashes and think something's broken. Suggest rewording so it's clear this echo verifies the input to electron-builder, not the BUNDLED pin:

          # Echo the extracted-binary SHA. This is the PRE-codesign digest
          # (i.e., the upstream tarball's `uv` byte-for-byte), useful for
          # confirming what feeds into electron-builder's codesign step.
          # NOTE: this is NOT directly comparable to BUNDLED_UV_SHA256[mac-arm64],
          # which is the POST-codesign digest — see backend-installer.cjs.
          # To bump BUNDLED_UV_SHA256[mac-arm64], run the CI build and copy
          # the SHA from the dmg-structural-smoke failure message.
          shasum -a 256 "${DEST_DIR}/uv"

Scope creep: claude.yml if: false is unrelated to #941 (.github/workflows/claude.yml:60)

The PR title and "Closes #941" both scope to the macOS uv bundle. Disabling pr-review (if: false, "credit balance exhausted") is operational and would have been cleaner as its own one-line PR — git blame will eventually point to this PR for that line and confuse anyone re-enabling auto-review later. Not a blocker; the disable is small, the rationale is in the inline comment, and the PR description does call it out — but worth flagging for next time. Consider a follow-up split or at least a Refs: line in the commit body for a013e384 so re-enable archeology lands faster.

Strengths

  • Shared helper extraction is excellent. tests/electron/_helpers/installer-smoke.mjs is the right level of abstraction: one source of truth for the in-resources path, BUNDLED_UV_SHA256 parsing, and the existence/mode/SHA assertion. The named exports (bundledUvPath, assertUvBinary, backendInstallerPath) read well at the call sites and pre-empt the AppImage↔DMG↔NSIS divergence bug: AppImage fails to launch — bundled uv SHA256 pin is the tarball hash, not the binary hash #849 + [Bug]: macOS installer (darwin-arm64) fails on first launch — bundled uv never shipped for mac-arm64 #941 sequenced through.
  • Comments earn their keep. Throughout the diff — the post-codesign SHA caveat in backend-installer.cjs:173-180, the node:test scheduling note in dmg-smoke.test.mjs:20-28, the regex stop-class rationale in installer-smoke.mjs:47-49, the VFS readdir-lag comment at dmg-smoke.test.mjs:101-105 — every non-obvious decision has a why. This is exactly the comment style CLAUDE.md asks for.
  • Defense in depth around cleanup. The finally { detach -force; rmSync } pattern, with errors logged-not-thrown so they cannot mask earlier assertion failures, plus the appEntry retry loop, plus the platform-mismatch skip for non-darwin runners — these are the marks of someone who's debugged this kind of test before.
  • Wiring is correct. The new dmg-structural-smoke job is added to build-complete.needs, the verifier loop and log line are updated to match (AppImage smoke job → Installer smoke job, "AppImage smoke suite" → "installer smoke suite"). A failing DMG smoke now blocks release-readiness, not just stares at it.

Verdict

Approve with suggestions. The structural fix and CI gate are solid; the four flagged items are all 🟢 minor — none of them blocks merge. Recommend addressing the workdir leak and the misleading comment before merge if it's cheap; the semver regex and scope-creep notes can be follow-ups.

…hasum echo

dmg-smoke.test.mjs: if hdiutil attach fails and the assert.equal throws, the
original try..finally block had not yet started so workdir leaked under
$TMPDIR for local re-runs (CI runners are ephemeral, so no CI impact). Fix:
move mkdirSync + attach into the try block, set attached=true only after a
successful attach, and guard hdiutil detach with if(attached) so a failed
attach does not produce a spurious 'no such volume' detach error. workdir
rmSync runs unconditionally in finally as before.

build-installers.yml: the shasum echo after the uv extract prints the
PRE-codesign digest, not the BUNDLED_UV_SHA256[mac-arm64] pin (which is
post-codesign). The old comment said 'cross-check BUNDLED_UV_SHA256[mac-arm64]'
which would mislead a maintainer into comparing two intentionally different
values. Reword to clarify the echo verifies the input to electron-builder,
and point to the dmg-structural-smoke failure message as the correct source
for the post-codesign pin.
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Solid, well-scoped fix for the macOS first-launch regression on clean Apple-Silicon Macs. The CI uv-fetch step mirrors the linux-x64 step, the new dmg-structural-smoke job is correctly wired into build-complete.needs: so future drift fails at smoke time rather than on a user's first launch, and the shared tests/electron/_helpers/installer-smoke.mjs extraction sets up the deferred Windows NSIS smoke as a near-trivial follow-up. The single most important thing the author should know: the post-codesign SHA pin protocol is correct and well-commented in backend-installer.cjs — but the bump procedure (run CI, copy the SHA from the dmg-structural-smoke failure) lives only in inline comments. The next maintainer will hit a confusing 2-PR loop on the next uv bump unless that lands in docs/reference/dev.mdx.

Most of the prior review feedback has been addressed in follow-up commits (workdir cleanup e01dee91, pre-codesign comment clarification d9b163db, VFS retry comment 3ffe52f2, etc.). The items below are what remains open.

Issues Found

🟡 Important

Semver regex contradicts its own comment (tests/electron/test_electron_chat_installer.js:699-700)

expect(pkg.version).toMatch(/^\d+\.\d+\.\d+$/);
expect(match[1]).toMatch(/^\d+\.\d+\.\d+$/);

The comment two lines above says "may legitimately differ pre-release," but the regex rejects PEP 440 pre-release suffixes (0.18.0rc1, 0.18.0.dev0, 0.18.0a1). Today both files use plain MAJOR.MINOR.PATCH so the test is green, but the next pre-release tag in version.py will trip a guard that its own comment claims should tolerate it.

      // package.json tracks the last *published* PyPI version; version.py is
      // bumped ahead of PyPI during development. They must match at release
      // time but may legitimately differ pre-release. Assert package.json has a
      // valid semver and is not AHEAD of version.py (that would be a bug).
      // Allows PEP 440 pre-release suffixes (rcN, .devN, aN, bN) on either side;
      // the lead-ahead comparison is on the numeric MAJOR.MINOR.PATCH prefix only.
      const SEMVER_RE = /^(\d+)\.(\d+)\.(\d+)([.\-+a-z0-9]*)$/i;
      const pkgMatch = pkg.version.match(SEMVER_RE);
      const pyMatch = match[1].match(SEMVER_RE);
      expect(pkgMatch).not.toBeNull();
      expect(pyMatch).not.toBeNull();
      const pkgParts = [pkgMatch[1], pkgMatch[2], pkgMatch[3]].map(Number);
      const pyParts = [pyMatch[1], pyMatch[2], pyMatch[3]].map(Number);
      const pkgAhead = pkgParts.some((n, i) =>
        n > (pyParts[i] ?? 0) && pkgParts.slice(0, i).every((m, j) => m === (pyParts[j] ?? 0))
      );
      expect(pkgAhead).toBe(false);

If you'd rather defer this until a real pre-release bump forces the issue, please add an explicit // TODO: relax regex when we ship a pre-release tag so the next maintainer knows the failure mode is anticipated, not a regression.

claude.yml if: false has no tracking issue or owner (.github/workflows/claude.yml:58-60)

# Temporarily disabled — Anthropic credit balance exhausted (see commit a013e384).
# To re-enable: restore the original `repository / event_name / draft / label` gate.
if: false

a013e384 is the commit that disabled it — pointing at it for "why" doesn't tell the next person who needs to act or when to expect a restore. This is the textbook shape of a if: false that lives forever. Two requests:

  1. Add a GitHub issue link in the comment (open one if it doesn't exist) so re-enable archeology takes seconds, not git-blame digging.
  2. Per CLAUDE.md "Scope-clean": this is genuinely orthogonal to issue [Bug]: macOS installer (darwin-arm64) fails on first launch — bundled uv never shipped for mac-arm64 #941 — consider splitting it into its own one-line PR before merge so future git log -- claude.yml doesn't surface a fix(installer): bundle uv binary for mac-arm64 commit. The PR description does call it out, which is good — but the title and Closes #941 still scope to the macOS uv bundle. Not a blocker; flagging the convention.

🟢 Minor

Post-codesign SHA bump protocol is undocumented in docs/reference/dev.mdx (PR-wide)

The comments in backend-installer.cjs:172-184 and the workflow's shasum -a 256 … echo (build-installers.yml:50-57) correctly explain that BUNDLED_UV_SHA256["mac-arm64"] is the post-codesign digest, and that the way to bump it is "run the CI build and copy the SHA from the dmg-structural-smoke failure message." That's a non-obvious 2-PR loop:

  1. PR A: bump BUNDLED_UV_VERSION + new tarball SHA in workflow + placeholder/old mac-arm64 digest in BUNDLED_UV_SHA256.
  2. Observe dmg-structural-smoke fail with the actual post-codesign hash in the message.
  3. PR B: paste the failure-message hash into BUNDLED_UV_SHA256["mac-arm64"].

No code change requested for this PR — but per CLAUDE.md "Every new feature must be documented," this is the kind of build-process gotcha that belongs in docs/reference/dev.mdx alongside the existing release/build instructions, not just in inline comments that a maintainer won't find until they're already mid-bump and confused. Worth a 5-line follow-up; reference issue #941 for context.

if: always() && needs.build.result == 'success' is if: needs.build.result == 'success' (.github/workflows/build-installers.yml:78)

The always() is a no-op when combined with && needs.build.result == 'success'. The existing appimage-structural-smoke job (line 545 in main) uses the same idiom, so this is consistent — but for clarity:

    needs: build
    if: needs.build.result == 'success'

If you'd rather stay symmetric with appimage-structural-smoke, leave as-is — purely a readability nit. (If you do touch it, change both jobs in one go so the convention stays consistent.)

Scope drift: SettingsModal → SettingsPage test rename and version-sync relaxation (tests/electron/test_electron_chat_app.js, tests/electron/test_electron_chat_installer.js)

These are defensible (rebase polish to keep CI green after independent main changes), but they are not implied by the title fix(installer): bundle uv binary for mac-arm64 and aren't in the PR description's "Why this matters." Per CLAUDE.md "Scope-clean: only the files required for the stated task are modified" — for a future PR, prefer either:

  • Carrying these in a chore(tests): rebase pickup or fix(tests): keep CI green precursor PR, or
  • Adding a one-line note to the PR body so the diff scope is self-explanatory.

Non-blocking for this PR.

Strengths

  • Comments earn their keep throughout. The post-codesign SHA caveat in backend-installer.cjs:172-184, the node:test scheduling footgun in dmg-smoke.test.mjs:18-26, the regex stop-class rationale in installer-smoke.mjs:46-49, the kernel-VFS readdir-lag justification at dmg-smoke.test.mjs:101-105, and the MUST be present in build-complete needs: reminder above the new job are exactly the why-not-what style CLAUDE.md asks for. This pattern is worth stealing elsewhere in the codebase.
  • Shared-helper extraction is the right level of abstraction. tests/electron/_helpers/installer-smoke.mjs consolidates the in-resources path layout (UV_RESOURCE_SUBPATH ↔ electron-builder.yml extraResources.to), the BUNDLED_UV_SHA256 parser, and the existence/mode-bit/SHA256 assertion. The named exports (bundledUvPath, assertUvBinary, backendInstallerPath) read well at call sites and reduce future Windows NSIS smoke to a ~30-line file. The single regex tied to one constant means a to: change in electron-builder.yml breaks every smoke test with the same actionable diff.
  • Mount-lifetime correctness. Wrapping subtests in a single async test() so hdiutil detach only fires after every assertion completes is a real node:test footgun the author called out and solved. The attached-flag guard on detach (added in d9b163db), the 10×200ms readdir loop for VFS lag, and the platform-mismatch skip for non-darwin runners are the marks of someone who's debugged this kind of test before.
  • Smoke gate genuinely catches the failure mode. assertUvBinary covers existence + mode-bit + SHA256-vs-pin, and T5c actually invokes uv --version — that last one transitively validates DMG mode-bit preservation and Gatekeeper quarantine, which a pure-existence check would miss. The fact that the same SHA assertion runs on both AppImage and DMG, sourced from one helper, is the right shape.
  • fileURLToPath over new URL(...).pathname in the helper avoids the well-known Windows path bug where pathname returns /C:/.... Small, correct, and a free pre-emptive fix for the deferred Windows NSIS smoke.

Verdict

Approve with suggestions. No blockers. The semver-regex / comment contradiction is the most actionable single change before merge; the claude.yml tracking-issue link and the post-codesign SHA documentation can land as follow-ups but are worth doing soon (the former so the disable doesn't outlive its rationale, the latter so the next uv bump isn't a 2-PR archaeology dig). Core installer fix and CI wiring are correct and well-documented; the test-helper refactor is a net win.

…k claude.yml issue

test_electron_chat_installer.js: the strict /^\d+\.\d+\.\d+$/ regex rejected
PEP 440 pre-release suffixes (rc1, .dev0, a1) even though the comment above it
said 'may legitimately differ pre-release'. Replace with SEMVER_RE that
captures the MAJOR.MINOR.PATCH triplet and tolerates any suffix; the
lead-ahead comparison now operates on the numeric prefix only, so a version.py
of 0.18.0rc1 and a package.json of 0.17.5 correctly passes.

claude.yml: add issue link (#970) to the if: false comment so re-enable
archeology takes seconds not git-blame digging.
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Targeted fix for #941 — bundles the mac-arm64 uv binary that bundledUvPlatformKey() already claimed support for, and adds a dmg-structural-smoke CI gate that catches the exact failure mode (missing/mismatched-SHA uv rejected by ensureUv() at first launch) before users hit it. The smoke-assertion logic is extracted into tests/electron/_helpers/installer-smoke.mjs so AppImage and DMG paths share one source of truth, with a clear extension point for the deferred NSIS variant. The PR is well-scoped, the code is heavily commented at the right places (post-codesign SHA semantics, node:test scheduling vs. live mounts, hdiutil detach timing), and it wires into build-complete so failures actually block release.

Issues Found

🟢 Minor

1. Path-filter widening triggers full installer builds on Jest-only edits (.github/workflows/build-installers.yml:13)

Switching the trigger from tests/electron/fixtures/** to tests/electron/** means a PR that touches only test_electron_chat_app.js (a Jest unit test that doesn't exercise the packaged installer at all) now spins up the multi-platform installer build. The reasoning given in the comment (smoke-test changes should trigger smoke) is sound, but the filter is broader than that — it also covers tests that have nothing to do with installer structure. Consider scoping to the smoke files specifically:

      # Cover the installer-smoke test tree (issue #941) so a PR that
      # only touches the smoke-test layer still triggers structural smoke.
      # Narrower than `tests/electron/**` so Jest-only edits to e.g.
      # test_electron_chat_app.js don't re-run the multi-platform build.
      - 'tests/electron/_helpers/**'
      - 'tests/electron/*-smoke.test.mjs'
      - 'tests/electron/fixtures/**'

Non-blocking — happy to defer if the broader filter is intentional.

2. Version-sync test now silently allows large divergences (tests/electron/test_electron_chat_installer.js:645-712)

The new pkgAhead check correctly catches the "package.json got bumped past version.py" bug. But it allows arbitrarily large behind gaps — package.json: 0.17.5 while version.py: 0.20.0 would pass cleanly, even though that's almost certainly a release-bump miss rather than an intentional pre-release lead. Consider also flagging when the major or minor differ:

      const pkgParts = [pkgSemver[1], pkgSemver[2], pkgSemver[3]].map(Number);
      const pyParts = [pySemver[1], pySemver[2], pySemver[3]].map(Number);
      const pkgAhead = pkgParts.some((n, i) =>
        n > (pyParts[i] ?? 0) && pkgParts.slice(0, i).every((m, j) => m === (pyParts[j] ?? 0))
      );
      expect(pkgAhead).toBe(false);
      // Lead is OK on PATCH only; MAJOR/MINOR drift is almost always a
      // missed release bump on the package.json side.
      expect(pkgParts[0]).toBe(pyParts[0]);
      expect(pkgParts[1]).toBe(pyParts[1]);

Optional — depends on how aggressively you want this to enforce sync.

3. Disabled Claude review job — consider deletion or expiry comment (.github/workflows/claude.yml:60)

if: false with a tracking issue is fine and the comment is clear. Two small suggestions:

  • Add a date so future readers know how stale "credits exhausted" is. Easy to forget a if: false for months.
  • Once Re-enable claude.yml pr-review job (Anthropic credit balance) #970 is resolved, the diff to re-enable should be a one-liner — the comment says "restore the original gate", but inlining the gate as # if: |\n # github.repository == 'amd/gaia' && … would make re-enable a literal uncomment.
    # Temporarily disabled 2026-05 — Anthropic credit balance exhausted
    # (see commit a013e384). Tracked for re-enable in
    # https://github.com/amd/gaia/issues/970. To re-enable, replace the
    # `if: false` line below with this commented gate:
    # if: |
    #   github.repository == 'amd/gaia' &&
    #   github.event_name == 'pull_request_target' &&
    #   (github.event.pull_request.draft == false ||
    #    contains(github.event.pull_request.labels.*.name, 'ready_for_ci'))
    if: false

4. AC4/T3 has become a thin existence-only test (tests/electron/appimage-smoke.test.mjs:142-145)

After the helper extraction, the first block does assert.ok(fs.existsSync(uvPath)) — and then T3b runs assertUvBinary() which also checks existence (and mode, and SHA). The standalone existsSync is now strictly redundant; the inline comment acknowledges the block is kept for "CI-log name stability". That's a defensible reason, but if log-name stability is the only motive, consider moving the t.skip pattern instead so the redundancy is explicit:

test("AC4/T3: bundled uv binary is present under extraResources", (t) => {
  // Subsumed by AC4/T3b (assertUvBinary). Block retained for CI-log
  // name stability — see _helpers/installer-smoke.mjs.
  t.skip("subsumed by AC4/T3b");
});

Tiny nit — current state works, this just makes intent louder.

Strengths

  • Single source of truth for the resource path layout. UV_RESOURCE_SUBPATH = ["vendor", "uv"] in the new helper is anchored to electron-builder.yml's to: vendor/uv config — verified that they match. If electron-builder.yml ever changes the to: path, every smoke test breaks at the same line with an actionable diff. This is exactly the kind of cross-file-coupling guard rail the codebase needed.

  • The post-codesign SHA distinction is well-documented in three places. backend-installer.cjs:80-87 explains the per-platform SHA origin (Linux raw, Mac post-codesign), the CI fetch step at build-installers.yml:50-57 echoes the pre-codesign digest with a NOTE that it is not what BUNDLED_UV_SHA256[mac-arm64] should match, and the bump procedure ("run the CI build, then copy the SHA from the dmg-structural-smoke failure message") is documented in both files. This is the kind of subtle codesign foot-gun that tends to bite a future maintainer six months after the original author has moved on — it is now genuinely hard to get wrong.

  • node:test scheduling-vs-live-mount footgun handled correctly. The DMG smoke test wraps mount-dependent assertions in a single async top-level test() and uses t.test() subtests so the finally { detach() } runs after every subtest body, not after registration. The header comment in dmg-smoke.test.mjs:30-39 explains the trap explicitly. The attached flag also avoids the "detach on a never-attached volume" path. -force on detach is correct for Spotlight-busy mounts on shared CI runners.

  • AC3/T5c — uv --version actually runs. The existence + SHA + mode-bit checks are necessary but not sufficient for macOS; Gatekeeper quarantine and stale codesign manifest could let the binary pass all three and still fail at runtime. The exec-time check catches both, and the comment makes the rationale explicit.

Verdict

Approve with suggestions. No blocking issues. The four minor items above are quality-of-life polish — none of them affect correctness of the mac-arm64 fix or the smoke gate. Happy to see this merge once the test plan items (real DMG install on a clean Apple Silicon Mac, ~/.gaia/bin/uv --version) check out.

…self-documenting

build-installers.yml: tests/electron/** was too broad — a PR touching only
test_electron_chat_app.js (a Jest unit test) would trigger the full
multi-platform installer build. Narrow to the specific smoke-test subtrees:
  _helpers/**, *-smoke.test.mjs, fixtures/**
This preserves the original intent (smoke-layer changes trigger structural
smoke) without paying the ~15-min cross-platform build cost for Jest-only edits.

claude.yml: add 2026-05 date so staleness is obvious at a glance, and inline
the original gating expression as a commented block so re-enabling is a literal
uncomment rather than a git-blame archaeology dig.
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Solid, well-reasoned fix for the v0.17.5 first-launch failure on Apple Silicon. The CI step that fetches uv-aarch64-apple-darwin mirrors the existing Linux step, the new dmg-structural-smoke job is correctly wired into the build-complete gate, and the shared _helpers/installer-smoke.mjs module is the right refactor — single source of truth for vendor/uv layout and SHA parsing across AppImage and DMG smoke tests, with an obvious extension point for NSIS. Comments consistently include why (issue refs, failure modes, lockstep dependencies), which is exactly the level of rigor this kind of packaging glue needs. The single most important thing for the author: the BUNDLED_UV_SHA256["mac-arm64"] pin is post-codesign while linux-x64 is pre-codesign — that asymmetry is documented in backend-installer.cjs:81-91 and is the right runtime semantics, but it's a long-term footgun that future contributors will trip over; the comment is the only safety net.

Issues

🟡 Important

None blocking.

🟢 Minor

  • Scope creep beyond the stated title (.github/workflows/claude.yml, tests/electron/test_electron_chat_app.js, tests/electron/test_electron_chat_installer.js). Per CLAUDE.md's "Scope-clean" rule, a fix(installer): bundle uv binary for mac-arm64 PR should ideally not bundle the pr-review disable, the SettingsModal → SettingsPage test rename, or the version-sync guard. The PR description acknowledges the claude.yml piece explicitly and the others are needed to keep CI green for this branch, so this is a heads-up rather than a request — but next time consider splitting (ci(claude): disable pr-review pending credit refresh, test(electron): rename SettingsModal → SettingsPage, test(ci): tolerate pre-release semver in version-sync guard) so reviewers can evaluate each independently.

  • win-x64 is still claimed by bundledUvPlatformKey() (backend-installer.cjs:665) but absent from BUNDLED_UV_SHA256 — the same failure mode this PR fixes for mac-arm64 is still latent for Windows users. The deferral comment at backend-installer.cjs:81-83 calls this out, and the issue tracker presumably has the follow-up. Not a regression of this PR; flagging only so it doesn't get forgotten under the now-passing macOS smoke.

  • parseBundledUvSha regex stop-class is [^}]*? (tests/electron/_helpers/installer-smoke.mjs:48). Today the dict body contains nothing but quoted hex strings, so this is safe and the comment correctly justifies it. If anyone ever adds a JS template-literal comment containing } inside the dict body the regex will match early — low likelihood, but a \b"linux-x64"\s*: style anchor or stripping comments first would be more robust. Not worth changing in this PR.

  • Version-sync guard treats 0.17.5 as not-ahead-of 0.17.5-rc1 (tests/electron/test_electron_chat_installer.js:653-664). Because the lead-ahead comparison is on the numeric MAJOR.MINOR.PATCH prefix only, a released package.json would silently pass against a version.py still on a pre-release of the same triple. Probably fine — the comment explicitly scopes the guard to the numeric prefix and the documented release flow keeps the two in sync at tag time — but worth a one-line note in the comment if you want to be explicit:

        // package.json tracks the last *published* PyPI version; version.py is
        // bumped ahead of PyPI during development. They must match at release
        // time but may legitimately differ pre-release. Assert package.json has a
        // valid semver and is not AHEAD of version.py (that would be a bug).
        // Allows PEP 440 pre-release suffixes (rcN, .devN, aN, bN) on either side;
        // the lead-ahead comparison is on the numeric MAJOR.MINOR.PATCH prefix
        // only — a released pkg vs a pre-release py with the same triple will
        // not flag here, which is intentional (release tagging closes that gap).
    
  • dmg-structural-smoke if: always() && needs.build.result == 'success' (build-installers.yml:79) — if: always() is redundant when paired with an explicit success check on needs.build; the matching appimage-structural-smoke job at line 540-ish uses the same pattern so consistency wins, leave as is. (Mentioning only because the if: always() reads as "run unconditionally" until you read the next clause.)

Strengths

  • _helpers/installer-smoke.mjs is the right factoring. UV_RESOURCE_SUBPATH, bundledUvPath, parseBundledUvSha, assertUvBinary, and backendInstallerPath are each one obvious thing, with docstrings that name the failure mode they catch rather than the operation they perform. The "two named test blocks preserved for output stability with prior CI logs" note in appimage-smoke.test.mjs:128-131 is a particularly nice touch — it preempts a reviewer who'd otherwise ask "why are these split?"
  • The DMG mount lifecycle in dmg-smoke.test.mjs is genuinely careful. The async-test wrapper rationale (:23-30), the attached flag guarding detach (:65-66), the -force justification (Spotlight), the VFS-readdir retry loop (:106-111), and the "errors logged but never thrown" detach contract (:148-159) all show this was written by someone who has actually been bitten by hdiutil on macos-latest. The AC3/T5c: uv --version runs test catching Gatekeeper/quarantine failure modes that pure SHA checks miss is exactly the right level of paranoia for this fix.
  • The post-codesign SHA bump procedure in backend-installer.cjs:81-91 ("run the CI build, then copy the SHA from the dmg-structural-smoke failure message — never from shasum against the freshly downloaded tarball") preempts the most likely future contributor mistake. Pairing the comment with the # To bump BUNDLED_UV_SHA256[mac-arm64]... echo line in the CI step (build-installers.yml:262-270) means the failure message itself will tell the next person what to do — rare-and-good.
  • Path-filter narrowing on installer-build (build-installers.yml:96-101) is the right call: tests/electron/_helpers/** and tests/electron/*-smoke.test.mjs trigger the multi-platform build, but Jest-only edits to test_electron_chat_app.js no longer do. Saves a meaningful amount of CI time without hiding installer-relevant changes.

Verdict

Approve with suggestions — the fix is correct, the test scaffolding is excellent, and the only nits are scope-hygiene and one optional comment tweak. Safe to merge once dmg-structural-smoke is green on this branch (per the test plan); the in-PR Minor items don't block.

kovtcharov-amd
kovtcharov-amd previously approved these changes May 6, 2026
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Solid, well-scoped fix for the v0.17.5 darwin-arm64 first-launch breakage. The PR mirrors the existing Linux uv-fetch step for macOS, extracts shared smoke-test assertions into tests/electron/_helpers/installer-smoke.mjs so AppImage and DMG paths can't drift, and wires the new dmg-structural-smoke job into the build-complete gate so any future regression fails CI rather than user installs. Comments are exceptionally good — the post-codesign-vs-pre-codesign SHA distinction is documented in three places and the node:test mount-lifetime footgun is called out where it matters. The single most important thing to note is that the mac-arm64 SHA pin is a post-codesign digest, which couples the runtime hash check to electron-builder's signing identity (see "Important issues" below).

Issues Found

🟡 Important

Post-codesign SHA pin will break on signing-cert/identity changes (src/gaia/apps/webui/services/backend-installer.cjs:84-91, .github/workflows/build-installers.yml:267-273)
The BUNDLED_UV_SHA256["mac-arm64"] value is the digest after electron-builder codesigns the bundled uv. That means any change to the Apple signing identity, codesign tool version, or entitlements will produce a different binary and trip both dmg-structural-smoke and the runtime ensureUv() check on first launch — even though nothing about uv itself changed. The bump procedure ("run CI, copy SHA from smoke failure") is documented, which is good, but the failure mode shows up as a SHA mismatch and the recovery path needs to be obvious to whoever's on call when this fires unexpectedly. Two suggestions, neither blocking:

  1. Add a single sentence to the smoke-test failure message itself pointing at the bump procedure (so the on-call engineer doesn't have to read backend-installer.cjs to know what to do).
  2. Consider a follow-up to switch to verifying the pre-codesign SHA at smoke time and treating codesign output as opaque — but that requires hashing before electron-builder runs, so it's not a small change.

This isn't a blocker for shipping the fix (the current pin is correct and the docs are honest about the pitfall), just calling it out so it doesn't bite later.

🟢 Minor

Scope-mixing: claude.yml disable and Jest-test renames are bundled with the installer fix (.github/workflows/claude.yml:60-68, tests/electron/test_electron_chat_app.js, tests/electron/test_electron_chat_installer.js)
The PR description does call these out, which is the right thing to do. But per CLAUDE.md's scope-clean rule, three logically independent threads (uv-mac fix, claude.yml credit-disable, SettingsModal→SettingsPage Jest rename, version-sync pre-release tolerance) ideally land as separate PRs. They're all small and well-justified individually, so I'd merge as-is — just flagging that the next time a similar bundle comes up, splitting makes review and git blame cleaner. No change requested.

T5b/T5c silently skipped when T5a fails (tests/electron/dmg-smoke.test.mjs:128-162)
If appEntry is undefined after the 2 s wait loop, T5a fails (correct) but T5b and T5c don't run at all (no skip emitted, no failure recorded). For someone debugging a CI failure where the DMG is malformed at the artifact layer, seeing only "no .app found" without explicit skips for the downstream checks is mildly confusing. Optional — emit explicit skips so the CI log shows three subtest results regardless:

      if (appEntry) {
        const resourcesDir = path.join(
          mountpoint,
          appEntry,
          "Contents",
          "Resources",
        );
        const uvPath = bundledUvPath(resourcesDir, PLATFORM_KEY);
        const installerPath = backendInstallerPath(import.meta.url);

        // ── AC3/T5b: existence + mode bit + SHA256 against pin ────────
        await t.test(
          "AC3/T5b: bundled mac-arm64 uv is present, executable, sha-pinned",
          () => {
            assertUvBinary(uvPath, PLATFORM_KEY, installerPath);
          },
        );

        // ── AC3/T5c: `uv --version` actually runs ─────────────────────
        // Catches Gatekeeper-quarantine and stale-code-sign failure
        // modes that pure existence/SHA checks miss. Also transitively
        // validates DMG mode-bit preservation: if APFS dropped the
        // executable bit, execFileSync fails with EACCES.
        await t.test("AC3/T5c: bundled mac-arm64 uv --version runs", () => {
          const out = execFileSync(uvPath, ["--version"], {
            timeout: 10_000,
            encoding: "utf8",
          });
          assert.match(
            out,
            /^uv \d+\.\d+\.\d+/,
            `unexpected uv --version output: ${out}`,
          );
        });
      } else {
        await t.test("AC3/T5b: bundled mac-arm64 uv (skipped — no .app)", (st) => {
          st.skip("T5a failed to locate .app bundle; downstream checks cannot run");
        });
        await t.test("AC3/T5c: bundled mac-arm64 uv --version (skipped — no .app)", (st) => {
          st.skip("T5a failed to locate .app bundle; downstream checks cannot run");
        });
      }

Local DMG smoke against an unsigned local build will always fail (tests/electron/dmg-smoke.test.mjs:5-11)
The "Locally" instructions tell a contributor to npm run package:mac && GAIA_DMG=... node --test, but a local build won't have the org's Apple signing cert, so uv won't be code-signed and its SHA will not match BUNDLED_UV_SHA256["mac-arm64"]. Worth a one-liner in the header comment so a contributor doesn't burn an hour debugging the "expected" mismatch:

// Requires the environment variable GAIA_DMG to point at an already-built
// DMG. In CI this is set after actions/download-artifact. Locally:
//   cd src/gaia/apps/webui && npm run package:mac
//   GAIA_DMG=$(ls src/gaia/apps/webui/dist-app/*.dmg) \
//     node --test tests/electron/dmg-smoke.test.mjs
//
// NOTE: the AC3/T5b SHA check compares against the POST-codesign digest in
// BUNDLED_UV_SHA256["mac-arm64"]. A local build without Apple signing certs
// (CSC_LINK unset) will produce an unsigned uv binary whose SHA will NOT
// match — that's expected. Local smoke runs are most useful for T5a (.app
// presence) and T5c (`uv --version` runs); T5b is meaningful only for
// signed CI builds.

parseBundledUvSha regex assumes no } in object-literal comments (tests/electron/_helpers/installer-smoke.mjs:55-69)
The [^}]*? stop-class is fine today (no } appears between the { and any platform key in BUNDLED_UV_SHA256), and the existing comment notes it. If a future contributor adds an inline comment like // e.g. {hash} inside the object literal, the regex silently fails to match and parseBundledUvSha throws. Low likelihood, no action needed unless you want to harden — switching to a per-line ^\s*"<key>"\s*:\s*"<sha>" regex with m flag would sidestep the brace-counting concern entirely.

Strengths

  • DRY refactor of smoke assertions into _helpers/installer-smoke.mjs is well-executed: single source of truth for the in-resources path layout, one regex for SHA parsing, one helper for full existence+mode+SHA check. The diff against appimage-smoke.test.mjs is a clean reduction (-46 lines, no behaviour change), and the new file is set up to absorb a future NSIS smoke without further refactoring.
  • Path-filter discipline is on point: tests/electron/_helpers/** and tests/electron/*-smoke.test.mjs are narrow enough to skip the multi-platform build for Jest-only edits, but wide enough to catch any future smoke variant. The comment explaining the trade-off is helpful for the next person to touch this filter.
  • Mount-lifetime + cleanup design in dmg-smoke.test.mjs is exactly right for node:test: the async wrapper holding the mount alive for all subtests, the attached flag guarding hdiutil detach, the -force flag for Spotlight contention, and the never-throw error logging in the finally so detach failures don't mask assertion failures. The "node:test scheduling vs. live mounts" comment block is genuinely educational and prevents the obvious refactor mistake.
  • build-complete gate wiring is correct — the new job is in needs:, the failure-aggregation loop includes dmg_result, and the success message is generalized from "AppImage smoke" to "installer smoke" so the log line stays accurate as more platforms come online.
  • Pre-release version-sync logic in test_electron_chat_installer.js is a careful bit of work — the lead-ahead comparison on numeric prefix only (with PEP 440 suffix tolerance on either side) handles the same-triple pre-release case cleanly, and the comment explains why the gap is intentional.

Verdict

Approve with suggestions. No blocking issues. The 🟡 cert-coupling note is a long-term operational concern, not a blocker for shipping the macOS first-launch fix. The 🟢 suggestions (silent-skip clarity, local-build SHA caveat, regex hardening) are small polish items the author can take or leave. Solid, ship it once dmg-structural-smoke goes green on this branch.

…al-build note

installer-smoke.mjs: expand the SHA mismatch error to include the actual hash
and the exact file+key to update — the on-call engineer no longer needs to
read backend-installer.cjs to know how to recover.

dmg-smoke.test.mjs:
- Add a NOTE block to the file header warning that local builds without Apple
  signing certs (CSC_LINK unset) will produce an ad-hoc-signed uv whose SHA
  will not match BUNDLED_UV_SHA256[mac-arm64] — T5b is expected to fail
  locally; T5a and T5c remain useful.
- Emit explicit t.skip() calls for T5b and T5c when T5a fails to find a
  .app bundle, so the CI log always shows three subtest results and the
  gap is obviously upstream rather than mysteriously absent.
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR fixes a hard-fail on first launch for clean Apple-Silicon Macs (no system uv) by adding a CI fetch step for uv-aarch64-apple-darwin, pinning the post-codesign SHA in BUNDLED_UV_SHA256, and wiring a new dmg-structural-smoke job into the build-complete gate. The shared tests/electron/_helpers/installer-smoke.mjs extract is a clean DRY refactor that puts AppImage and DMG smoke on the same well-documented path. Overall the change is well-scoped, defensively layered (CI-time tarball SHA → smoke-time packaged SHA → runtime SHA), and the test code is unusually well-commented about its non-obvious failure modes. No blocking issues.

Issues Found

🟢 Minor

Scope: undocumented test catch-up (tests/electron/test_electron_chat_app.js)
The SettingsModal → SettingsPage rename test catch-up is correct (the rename landed in 37e35eb1 and tests had drifted), but it isn't mentioned in the PR description, which only calls out the claude.yml disable as the bundled side-thread. Per CLAUDE.md's "Scope-clean" guidance, either drop the change or add a one-liner thread bullet to the description. Not a blocker — the change itself is correct.

Redundant nullish coalescing in version-sync guard (tests/electron/test_electron_chat_installer.js:664-666)

const pkgAhead = pkgParts.some((n, i) =>
  n > (pyParts[i] ?? 0) && pkgParts.slice(0, i).every((m, j) => m === (pyParts[j] ?? 0))
);

SEMVER_RE already requires three numeric groups, so both pyParts and pkgParts are always length 3 — the ?? 0 fallbacks are dead code. Logic is otherwise correct (verified against pkg=0.17.5/py=0.17.6 → false; pkg=0.17.6/py=0.17.5 → true; pkg=0.17.5/py=0.17.5rcN → false, which the comment flags as intentional).

      const pkgAhead = pkgParts.some(
        (n, i) =>
          n > pyParts[i] &&
          pkgParts.slice(0, i).every((m, j) => m === pyParts[j]),
      );

assertUvBinary re-reads installer.cjs on every call (tests/electron/_helpers/installer-smoke.mjs:55-69)
Each smoke test calls parseBundledUvSha once, so this is fine today. Worth a comment noting the helper assumes a single call per test invocation, in case a future caller loops over platform keys (linux + mac + win in one process).

Not actionable — flagging for awareness.

Strengths

  • Layered SHA defense, clearly delineated: the CI Fetch uv binary (macOS) step verifies the upstream tarball SHA (supply-chain), the smoke job verifies the post-codesign packaged SHA (electron-builder integrity), and ensureUv() verifies it again at runtime. The backend-installer.cjs:80-91 comment block explicitly documents that the linux pin is pre-codesign while the mac pin is post-codesign — exactly the kind of non-obvious WHY-comment CLAUDE.md asks for.
  • Test scheduling pitfall handled correctly: the dmg-smoke.test.mjs:27-35 and :73-201 block correctly wraps the mount-dependent assertions in a single async test(...) with t.test() subtests so finally { hdiutil detach } runs after all assertions. The attached flag (:82, 111, 180) avoids spurious detach errors when attach itself fails. This is the kind of subtle async/mount lifecycle issue that's easy to get wrong; comments explain the failure mode if a future contributor "simplifies" it.
  • Smoke-job wiring is complete: dmg-structural-smoke is added to build-complete.needs (build-installers.yml:1058), the loop variable r covers dmg_result, and the failure message generalised from "AppImage smoke" → "Installer smoke". A failing DMG smoke now actually blocks release-readiness, which the inline comment correctly emphasises.
  • Path-filter narrowing: tests/electron/*-smoke.test.mjs instead of tests/electron/** is the right granularity — Jest-only edits to test_electron_chat_app.js won't trigger a 15min cross-platform build. The inline comment explains the trade-off.
  • DRY helper module: _helpers/installer-smoke.mjs is a clean extraction with three small, single-purpose functions; UV_RESOURCE_SUBPATH as a single source of truth that mirrors electron-builder.yml is good defensive design — the comment on lines 22-25 spells out the failure mode if the layouts drift.

Verdict

Approve with suggestions — the only actionable nit is the dead-code ?? 0 fallback in the version-sync guard. The PR description scope mention (the SettingsPage test rename) is a minor housekeeping ask, not a merge blocker.

SEMVER_RE guarantees exactly three captured numeric groups, so
pyParts[i] is never undefined and the ?? 0 fallbacks are unreachable.
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes the v0.17.5 macOS regression (#941): the DMG advertised darwin-arm64 support in backend-installer.cjs but the build job never fetched a uv binary, so first-launch on a clean Mac hard-failed in ensure-uv. The fix bundles the pinned uv 0.5.14 aarch64-apple-darwin binary, adds a dmg-structural-smoke CI gate that mirrors the existing AppImage gate, and DRY-extracts shared assertions into tests/electron/_helpers/installer-smoke.mjs. The most important thing to know: the mac-arm64 SHA in BUNDLED_UV_SHA256 is post-codesign (set by electron-builder during packaging), not the upstream tarball digest — that asymmetry vs. linux-x64 is now well documented in both backend-installer.cjs:84-91 and the CI step's echo comment.

This is a clean, well-iterated PR with good commit hygiene, thorough rationale comments, and an acceptance-criteria-mapped test layout.

Issues Found

No 🔴 or 🟡 issues. A couple of optional observations:

  • 🟢 Path filter bypass for fork PRs — the claude.yml pr-review job is gated on if: false with a clear re-enable comment, but the if line is now the only gate, so the prior github.repository == 'amd/gaia' check is also disabled. Not an issue today (the job is fully off), but worth flagging when re-enabling per Re-enable claude.yml pr-review job (Anthropic credit balance) #970: don't accidentally drop the fork-safety gate when uncommenting.

  • 🟢 appEntry retry loop has no log on failure (tests/electron/dmg-smoke.test.mjs:69-74) — the eventual T5a assertion does report the directory listing, so this is actionable already, but if you ever see flakes here you'll want a console.error inside the loop indicating which iteration finally succeeded. Not worth changing now; mentioning so future-you doesn't burn time tracking down silent retries.

  • 🟢 Helper regex is platform-key safe but not platform-key strict — parseBundledUvSha accepts arbitrary platformKey strings and escapes regex metacharacters. Today the JSDoc enumerates the three valid keys (linux-x64|mac-arm64|win-x64); a future TS migration could harden this to a literal union, but the current shape is reasonable for a .mjs helper.

Strengths

  • Excellent DRY refactor: extracting assertUvBinary / bundledUvPath / parseBundledUvSha / backendInstallerPath into _helpers/installer-smoke.mjs means the future NSIS smoke test (Windows uv.exe) drops in trivially — the win-x64 branch is already wired into bundledUvPath and the executable-bit check is correctly skipped on Windows.
  • Comments earn their keep: the WHY for non-obvious decisions is captured directly where it matters — the post-codesign vs. raw-tarball SHA difference (backend-installer.cjs:81-91 and the CI echo step), the node:test scheduling pitfall that motivates wrapping mount-dependent assertions in a single async test() (dmg-smoke.test.mjs:30-39), and the -force detach rationale (dmg-smoke.test.mjs:88-93). This is the kind of inline doc that actually pays off six months later.
  • Self-documenting workflow disable: claude.yml keeps the original if: condition as a comment block alongside the if: false, with an explicit issue link (Re-enable claude.yml pr-review job (Anthropic credit balance) #970) and a one-line re-enable recipe. Better than a bare if: false or a deleted file.
  • Test-name stability through refactor: the two named blocks in appimage-smoke.test.mjs are intentionally preserved even though they collapse to single-line assertUvBinary calls, so prior CI logs stay diff-able. Small but considered.
  • Acceptance-criteria mapping: T5/T5a/T5b/T5c naming ties the smoke subtests directly back to issue [Bug]: macOS installer (darwin-arm64) fails on first launch — bundled uv never shipped for mac-arm64 #941, including explicit skipped subtests when T5a fails so the CI log shape stays stable. Makes future failure triage straightforward.
  • Version-sync guard tolerates legitimate dev-ahead drift (test_electron_chat_installer.js:648-665) — the new "pkg not ahead of py" assertion correctly captures the actual invariant (package.json tracks last published PyPI version; version.py leads during development) instead of demanding strict equality.

Verdict

Approve. Already maintainer-approved (kovtcharov-amd); my read agrees — no blocking issues, and the iterative commits show the rough edges from earlier review rounds (T5b/T5c skip behavior, path filter scope, version-sync semver tolerance) have all landed cleanly. Ship it.

@itomek
itomek added this pull request to the merge queue May 6, 2026
Merged via the queue into main with commit 7b13352 May 6, 2026
47 checks passed
@itomek
itomek deleted the claude/priceless-dubinsky-2a062c branch May 6, 2026 21:13
theonlychant pushed a commit to theonlychant/gaia that referenced this pull request May 7, 2026
…md#975)

## Why this matters

PR amd#968 landed with a stale comment in
[build-installers.yml](.github/workflows/build-installers.yml) that
claims the macOS uv fetch step was \"removed in this PR to keep changes
Windows-only\" — but the step is sitting right above the comment. The
comment is a leftover from PR amd#968's merge resolution: when main was
merged into the PR branch, the macOS step came back (PR amd#967 had added
it), but the orphan comment from an earlier Windows-only sub-commit
survived. After the squash-merge it now lies on main.

Before: workflow file contains a self-contradicting comment that
misleads anyone touching this section in the future (\"why does the
comment say it's removed when it's right there?\").
After: comment is gone, file matches reality.

No functional change — comment-only edit.

## Test plan

- [x] \`grep \"macOS uv fetch removed\"
.github/workflows/build-installers.yml\` returns nothing
- [x] Diff is comment-only (3 deletions, 0 functional changes)
theonlychant pushed a commit to theonlychant/gaia that referenced this pull request May 7, 2026
## Why this matters

Ships the v0.17.6 patch: a new Email Triage Agent with Gmail (every
email body stays on local Lemonade), the OAuth PKCE foundation that
backs it, settings UI card layout, and a sweep of installer fixes that
close the remaining first-launch failures uncovered after v0.17.5.
Custom Python agents that follow the template's
`super().__init__(**kwargs)` pattern no longer crash on the first
message in the Agent UI.

Full notes: `docs/releases/v0.17.6.mdx`.

## What's New

- **Email Triage Agent with Gmail**
([amd#965](amd#965)) — `EmailTriageAgent` with
25 tools across read / organize / reply / delete / calendar mixins.
Every email body processed locally on Lemonade; seven destructive tools
confirmation-gated; three layers of prompt-injection defense; SQLite
undo log via `DatabaseMixin`.
- **OAuth PKCE foundation for Google connections**
([amd#926](amd#926)) — Self-contained
`gaia.connections` module: refresh tokens in the OS keychain (Keychain /
DPAPI / SecretService), per-agent grants in
`~/.gaia/connections/grants.json`, async token cache with refresh
rotation. Baseline for the v0.17.7 connectors framework.
- **Settings UI card layout**
([amd#969](amd#969)) — Outlined cards with
accent left-stripe replace margin-separated blocks across all settings
sections; light + dark themes both updated.

## Bug Fixes

- **Custom Python agents crashed on first message**
([amd#974](amd#974), closes
[amd#973](amd#973)) — `python_factory` now
introspects the target class's `__init__` chain and only forwards kwargs
the chain accepts, so the bare `super().__init__(**kwargs)` template
pattern no longer crashes with `unexpected keyword argument
'rag_documents'`.
- **Windows installer failed at `ensure-uv`**
([amd#968](amd#968), closes
[amd#966](amd#966)) — `uv` binary now
bundled for `win-x64`; packaged Windows rescue installer included.
- **macOS installer failed at `ensure-uv` on clean Apple Silicon**
([amd#967](amd#967), closes
[amd#941](amd#941)) — Pinned `uv` v0.5.14
(`aarch64-apple-darwin`) shipped in the DMG; new `dmg-structural-smoke`
CI job blocks future drift.
- **AppImage users hit `gaia: command not found`**
([amd#942](amd#942), closes
[amd#782](amd#782)) — Startup writes a
`~/.local/bin/gaia` shim so `gaia` is on PATH after first launch (skips
creation if already present).
- **Windows fell back to Qwen instead of Gemma 4 default**
([amd#949](amd#949), closes
[amd#948](amd#948)) — Model-resolution logic
fixed so Gemma loads correctly on Windows.

## Tooling & Docs

- **`gaia-release` skill**
([amd#939](amd#939)) — Phased release flow
with hard gates before every irreversible step; encodes the manual
pre-tag verification that caught two release-blocking bugs in v0.17.4.
- **Internal-task issue template**
([amd#906](amd#906)) — Third issue template
for agent-assignable internal work.
- **Outlook via Power Automate plan**
([amd#954](amd#954)) — Enterprise-bypass spec
for v0.17.7 Outlook integration.
- **PR description guidance sharpened**
([amd#947](amd#947)) — `CLAUDE.md` "tight and
value-focused" rule with anti-patterns.
- **Stale `macOS uv fetch removed` orphan comment removed**
([amd#975](amd#975)).

## Thanks

External contributors in this release:

- [@theonlychant](https://github.com/theonlychant) — installer fixes
([amd#968](amd#968),
[amd#942](amd#942),
[amd#949](amd#949))
- [@BlueriteSoul](https://github.com/BlueriteSoul) — reported AppImage
`gaia: command not found`
([amd#782](amd#782))
- [@nuts23](https://github.com/nuts23) — reported Windows Gemma/Qwen
fallback ([amd#948](amd#948))

## Release checklist

- [x] `util/validate_release_notes.py docs/releases/v0.17.6.mdx --tag
v0.17.6` passes
- [x] `src/gaia/version.py` → `0.17.6`
- [x] `src/gaia/apps/webui/package.json` → `0.17.6`
- [x] Navbar label in `docs/docs.json` → `v0.17.6 · Lemonade 10.2.0`
- [x] All 14 commits in the range (v0.17.5..HEAD) are represented in the
notes
- [ ] Review from @kovtcharov-amd addressed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops DevOps/infrastructure changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: macOS installer (darwin-arm64) fails on first launch — bundled uv never shipped for mac-arm64

2 participants