Skip to content

fix(desktop): keep the updater inert until enterprise activation - #4726

Merged
yomgui merged 2 commits into
devfrom
fix/defer-updater-until-activation
Sep 10, 2026
Merged

yomgui merged 2 commits into
devfrom
fix/defer-updater-until-activation

Conversation

@yomgui

@yomgui yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member

Problem

Since #4482 DesktopUpdaterProvider mounts at AppRoot, above EnterpriseActivationGate, and #4606/#4696 made the contexts it needs (DesktopConfigProvider, LocalProvider) available in the pre-activation branch. The updater therefore runs before enterprise activation:

  • useElectronUpdaterState auto-checks on mount (updateAutoCheck defaults on) and auto-downloads (updateAutoDownload defaults on).
  • isUpdateAllowedByDesktopConfig returns true when allowedDesktopVersions is absent — always the case before activation, because no Den is known.
  • openwork:updater:check/download/installAndRestart had no assertDesktopActivation guard (only the openwork:desktop channel did).

In 0.18.42 the updater lived inside Settings, which never mounts pre-activation, so this is new in 0.18.43+. An unactivated enterprise install could check and stage the newest enterprise-channel release before the organization's allowed-versions policy was known, defeating the containment that organizations get by pinning versions in Den.

Confirmed dynamically on a packaged enterprise --dir build of origin/dev (c744e2d), fresh profile, no user action. Within 2 s of the renderer mounting Link this app to your organization, the Electron main log contained:

Checking for update
Found version 0.18.45 (url: openwork-enterprise-mac-arm64-0.18.45.zip, …)
Downloading update from openwork-enterprise-mac-arm64-0.18.45.zip, …

(The download then failed only because the unsigned --dir build has no app-update.yml; a signed release install would have staged it.)

Fix (smallest diff, providers stay mounted)

Renderer — desktop-updater-provider.tsx derives updatePolicyKnown = !useEnterpriseActivationRequired() && !desktopConfig.loading and passes it to useElectronUpdaterState, which now skips both the automatic check effect and the native-menu "Check for Updates…" effect until it is true. The !desktopConfig.loading half means the first post-activation check already sees allowedDesktopVersions (cached or freshly fetched) instead of the empty default. A menu request made too early stays queued and runs once the policy is known. Defaults for activated installs are unchanged.

Main process — registerUpdaterIpc takes assertActivation (default no-op); main.mjs passes the existing assertDesktopActivation. openwork:updater:check, download, and installAndRestart reject while desktopActivationRequired(DESKTOP_DISTRIBUTION, bootstrap) is true, before electron-updater is loaded or a feed selected, so no renderer path (including the menu) can reach the network early.

Proof

Check Command Lane Result
Main-process guard unit test (pre-activation guard) node --test apps/desktop/electron/updater.test.mjs local 34 pass / 0 fail (33 baseline + 1 new; new test red without the guard)
Desktop core tests pnpm --filter @openwork/desktop test:core local 136 pass / 0 fail
Journey packaged-preactivation-updater on unfixed enterprise build (origin/dev) OPENWORK_EVAL_ELECTRON_BINARY=… pnpm evals:e2e packaged-preactivation-updater --local local Failed as expected: update checks started before activation: Checking for update: expected 1 to be +0; positive control passed
Journey packaged-preactivation-updater on fixed enterprise build (this branch) same local Passed 2/2: no check/download for 20 s while the gate is on screen; activated bootstrap checks within ~4 s
Journey packaged-first-launch on fixed enterprise build (no regression) pnpm evals:e2e packaged-first-launch --local local Passed 1/1
App typecheck pnpm --filter @openwork/app typecheck local clean
Electron IPC-contract typecheck pnpm --filter @openwork/desktop typecheck:electron local clean
App unit tests touched bun test src/react-app/shell/providers.test.tsx, …/electron-updater-state.test.ts, tests/enterprise-activation.test.ts local 1/4/10 pass
Journey catalog node --test evals/scripts/journey-ci.test.mjs local 13 pass
evals typecheck (my files) pnpm --dir evals typecheck local 0 errors in specs/packaged-preactivation-updater.e2e.test.ts / worlds/packaged-preactivation-updater.ts; the 368 remaining errors are pre-existing on dev (packages/email jsx, worlds/session-shell.ts withResolvers, …)
Warden pnpm warden:check on 1f3f29b (bare mode vs dev) local exit 0; diff-security-review, confidentiality-review, spec-provenance-review, desktop-den-sync-review all completed, no findings

Lane: local for everything (Daytona not attempted: this journey needs the packaged enterprise binary produced by packaged-smoke, which is a placement: 'local' journey).

New journey evals/specs/packaged-preactivation-updater.e2e.test.ts + evals/worlds/packaged-preactivation-updater.ts: boots the packaged enterprise binary on a fresh profile, waits for the activation heading, then watches the main-process log (electron-updater's Checking for update / Downloading update from) for a 20 s quiet window. Positive control boots the same binary with an enterpriseActivation bootstrap (unreachable Den) and asserts the check attempt appears. Registered in journey-catalog.mjs (placement: 'local') and added as the desktop-updater-gate-enterprise phase in packaged-smoke.mjs, reusing the enterprise binary that script already packages.

Not covered

  • The journey witnesses electron-updater's main-process log lines, not the IPC call itself; the unit test covers the IPC rejection directly.
  • The positive control asserts only that a check is attempted (network may refuse the manifest); it does not assert the staged version.
  • macOS/Windows packaged runs of the journey only happened locally (macOS); CI runs it on Linux through packaged-smoke.
  • Adds roughly 40–50 s to the packaged smoke gate (fresh boot + 20 s quiet window + activated boot).

Since #4482 the updater provider mounts above the enterprise activation gate,
and #4606/#4696 made the contexts it needs available there. A fresh enterprise
install therefore checked the enterprise release feed and started staging the
newest release within ~2 s of first launch, before any Den (and so any
allowed-versions policy) was known.

Renderer: automatic and menu-requested checks wait until activation is complete
and the desktop config has resolved once, so the first check already honours
allowedDesktopVersions. Main process: openwork:updater:check/download/
installAndRestart reject through assertDesktopActivation while activation is
required, so no renderer path can reach electron-updater early.

Proof: unit test for the IPC guard, and the packaged-preactivation-updater
journey (red on the unfixed enterprise build, green after) wired into the
packaged smoke gate.
@vercel

vercel Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

4 Skipped Deployments
Project Deployment Actions Updated
openwork-app Ignored Ignored Preview Sep 10, 2026 2:41am UTC
openwork-den Ignored Ignored Preview Sep 10, 2026 2:41am UTC
openwork-diagnostics Ignored Ignored Preview Sep 10, 2026 2:41am UTC
openwork-landing Ignored Ignored Preview Sep 10, 2026 2:41am UTC

@yomgui

yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

Additional test evidence (same head 1f3f29b)

The sticky test-evidence comment above holds the negative half. The legacy single-run publisher replaces that comment on each publish and the composed multi-run review needs the private review Blob token, which is not available locally, so the other two runs are quoted here.

Positive control — an activated enterprise install still checks for updates — ✅ passed (run evals/results/test-runs/2026-09-10T02-34-18-374Z-an-activated-enterprise-install-still-checks-for-updates, SHA 1f3f29b, local lane)

  • probe.eventually(update check after activation) resolved after ~3 s; user.notSee(text=Link this app to your organization) held.
  • ASSERTION PASS — main-process updater lines: ["Checking for update","Found version 0.18.45 (url: openwork-enterprise-mac-arm64-0.18.45.zip, …)"]

Red control — same journey against the unfixed enterprise build of origin/dev c744e2d — ❌ failed as intended

× an unactivated enterprise install does not check for or download updates 7869ms
✓ an activated enterprise install still checks for updates 3344ms
AssertionError: update checks started before activation: Checking for update: expected 1 to be +0

Repro for both: build the enterprise flavor (node apps/desktop/scripts/electron-build.mjs --server-built && CSC_IDENTITY_AUTO_DISCOVERY=false pnpm --dir apps/desktop exec electron-builder --config electron-builder.enterprise.yml --mac --dir --publish never --config.directories.output=<out>), then OPENWORK_EVAL_ELECTRON_BINARY="<out>/mac-arm64/OpenWork Enterprise.app/Contents/MacOS/OpenWork Enterprise" OPENWORK_EVAL_ELECTRON_RESOURCES_PREPARED=1 OPENWORK_EVAL_ENGINE=v1 pnpm evals:e2e packaged-preactivation-updater --local.

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Warden review summary — Clear

Native findings: 1. Blocking policy matches before consolidation: 0. Full finding text remains in Warden's native checks and review threads. This comment retains only native IDs, severity, skill attribution, and safe locations. Analysis run

Reported trigger coverage (not proof of complete repository or context coverage): diff-security-review (123631 ms), confidentiality-review (113712 ms), spec-provenance-review (149060 ms), desktop-den-sync-review (176002 ms).

Blockers

  • None.

Advisories

  • A9R-QP3 · medium · spec-provenance-review · evals/worlds/packaged-preactivation-updater.ts:24

Needs recheck

  • None.

Observed review-thread metrics

  • Unique observed run attempts in retained window: 2
  • Distinct heads in retained window: 2
  • Current unresolved Warden threads: 0 of 0 observed
  • Observed resolved/unresolved transitions in retained snapshots: 0 / 0
  • First observed resolved/unresolved (state at first collection, not event time): 0 / 0
  • Precision: unavailable (no adjudications; no TP/FP values are inferred)
  • Observation window: 2/20 run attempts retained; truncated: false
  • Transition snapshot: 0/0 current attributed threads retained (limit 500); truncated: false

Thread states are read-only collection snapshots. These metrics are neither lifetime totals nor exact resolution times, and this summary is not clearance authority.

diff-warden[bot]
diff-warden Bot previously approved these changes Sep 10, 2026

@diff-warden diff-warden Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (1f3f29b5506858157a3d8ab30a4d7ec5020ddf64). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

…empt

On the unpacked Linux directory the packaged smoke gate boots, electron-updater
answers checkForUpdates() with "APPIMAGE env is not defined" instead of
"Checking for update", so the positive control never saw the attempt in CI.

@diff-warden diff-warden Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (24e6377cdfeea435f1fa528468d86a717246103d). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@yomgui

yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

Test evidence — an unactivated enterprise install does not check for or download updates — ✅ passed

SHA 24e6377 · engine v1

✅ 0/1 screenshots passed · 1 assertion · 1 expectations passed · 0 failed · 0 pending

[probe] eventually(packaged distribution flavor) · eventually(enterprise activation gate mounted in #root)
[user] see(text=Link this app to your organization)
[probe] eventually(updater activity before activation)
[user] see(text=Link this app to your organization) · screenshot
verdict passed · 3 user observations (see ×2, screenshot ×1) · 3 probes · steps 0/0

ℹ️ ASSERTION — 1. An unactivated enterprise install starts no update check or download within 20s of showing "Link this app to your organization"

main-process updater lines: []

  • ✅ PASS An unactivated enterprise install starts no update check or download within 20s of showing "Link this app to your organization" — main-process updater lines: []

⚪ UNVALIDATED — 2. an unactivated enterprise install does not check for or download updates artifact 1

  • ⚪ UNVALIDATED — no visual expectations recorded.

an unactivated enterprise install does not check for or download updates artifact 1


Test run created 2026-09-10T02:40:25.728Z · Source: evals/results/test-runs/2026-09-10T02-40-25-727Z-an-unactivated-enterprise-install-does-not-check-for-or-download-updates/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4726 --test-run 2026-09-10T02-40-25-727Z-an-unactivated-enterprise-install-does-not-check-for-or-download-updates

@yomgui

yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

Evidence update for head 24e6377

The sticky test-evidence comment now shows the negative half on 24e6377 (local, macOS, main-process updater lines: [] over the 20 s window).

Positive control on 24e6377 — an activated enterprise install still checks for updates — ✅ passed (run evals/results/test-runs/2026-09-10T02-40-53-133Z-an-activated-enterprise-install-still-checks-for-updates, local lane, ~3 s): main-process updater lines ["Checking for update","Found version 0.18.45 (url: openwork-enterprise-mac-arm64-0.18.45.zip, …)"].

CI (Linux, packaged-smoke phase desktop-updater-gate-enterprise, run 34430402399): both halves passed in 26.7 s total — an unactivated enterprise install does not check for or download updates 22.0 s, an activated enterprise install still checks for updates 2.9 s. The first CI attempt (1f3f29b) timed out on the positive control because the unpacked Linux directory is not an AppImage, so electron-updater answers checkForUpdates() with APPIMAGE env is not defined instead of Checking for update; 24e6377 counts that refusal as the check attempt it is.

Local Warden (pnpm warden:check, bare mode vs dev) on 24e6377: exit 0, all four skills completed with no findings.

@yomgui

yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

Follow-ups filed: #4749 (packaged-smoke loses electron.log before artifact upload), #4750 (cleanStaleUpdaterState ignores overridden HOME in eval runs), #4751 (private review Blob token for local composed evidence publishing). Shipped in v0.18.46.

yomgui added a commit that referenced this pull request Sep 10, 2026
…et ShipIt finish (#4763)

Move the release-validation runbook into its own skill with the checks the
release section did not have: updater-manifest sha512 and asset presence,
codesign/notarization, a Daytona-Den lane, a clone helper so
packaged-first-launch never launches the extracted bundle (pre-#4726 builds
self-update before activation), and how to publish evidence. The release
skill keeps a pointer paragraph.

The released world now clones bundles with APFS clonefile (cp -Rc) instead
of a 250 MB copy and waits for Squirrel's ShipIt to finish before removing
them, so a quit-time install never leaves a half-applied bundle or a
resumable ShipIt state behind.
OmarMcAdam added a commit that referenced this pull request Oct 7, 2026
…5758)

The local host removes a host-owned Electron profile when a journey's world
is disposed, and electron.log lives inside that profile. The packaged smoke
upload glob profiles/**/electron.log therefore never matched, so a failing
packaged check (for example the Linux updater-gate timeout in #4726) left no
main-process log to read.

With OPENWORK_EVAL_SURFACE_LOGS_DIR set, disposeSurface now copies the
surface log there before removing the profile. packaged-smoke.mjs points it
at <output>/logs/<check>, outside the surfaces root that every launch prunes,
and both packaged-smoke uploads (ci-tests and pr-proof) include it.

Closes #4749

Signed-off-by: OmarMcAdam <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant