Skip to content

fix(updater): re-validate the desktop version policy before installing a downloaded update - #4761

Merged
yomgui merged 5 commits into
devfrom
fix/updater-revalidate-on-install
Sep 10, 2026
Merged

yomgui merged 5 commits into
devfrom
fix/updater-revalidate-on-install

Conversation

@yomgui

@yomgui yomgui commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Summary

Narrow follow-up to #4726: revalidate organization permission before explicit renderer install/restart of an already-downloaded version. This PR does not close the broader managed-updater finding; the same owner is handling remaining phases in #4767.

Changes

  • Refresh DesktopConfigProvider.refreshFresh before the renderer calls bridge.installAndRestart().
  • For stable, recheck the recorded downloaded version against isUpdateAllowedByDesktopConfig. The Den support decision was made at check time; this pure policy check avoids adding a network dependency for installing an already-approved download. Alpha keeps its existing channel/Den checks and reuses isAlphaUpdateAllowed for version eligibility.
  • If revoked, do not call the bridge. Set the existing blocked-policy status and clear the renderer's downloaded/available channel refs, removing the restart affordance and allowing a fresh check.
  • If desktop-config refresh fails, use the last known config. An absent allowlist retains its existing unrestricted meaning. This does not claim fresh managed-policy authorization while offline.
  • Settings and the titlebar restart confirmation share this updater function. The native menu exposes Check for Updates, not an independent renderer install function.

Validation

  • Local app typecheck: pnpm --filter @openwork/app typecheck, exit 0.
  • Local unit checks: pnpm --dir apps/app exec bun test --isolate tests/electron-updater-install-policy.test.ts tests/version-gate.test.ts, exit 0, 26 passed / 0 failed / 0 skipped.
  • The hook tests cover allowed, revoked, absent allowlist, refresh failure with cached permission, and refresh failure with cached revocation.
  • Real Den/fake updater feed journey: allow version, download, revoke via PATCH /v1/org, confirm titlebar restart, observe blocked UI and zero bridge installs; reapprove and freshly download, then install through Settings as the positive control. All three background-update/revocation/recovery cases passed on final head d5040026407c9b38d7c20328093cc7a5847d7013 in two complementary Daytona name-filtered runs (exit 0 each; all names covered). Evidence, commands, prior reds, and final local Warden review.
  • Test mechanics: await dialog dismissal, preserve branding across the fake refresh, and isolate manual retries from automatic checks using the real settings switch. Add the missing switch role/selector to CDP targeting; its unit file passes 8 tests and the journey asserts the changed preference.
  • Private Review upload was unavailable because the available Blob token is for a public store. Evidence is published in text on the PR without uploading records to that public store. The existing recovery witness had one unresolved timeout on an earlier head; it passed on the final head, and this PR does not claim to fix recovery.
  • Evals typecheck, spec-layer typecheck, layer lint and both ratchets fail identically on the PR and clean origin/dev control 634df629a919db504e27d0f00962dc772344e42a: respectively 366 errors, 9 errors, 39 violations, 19 and 14 ratchet failures. No added-line diagnostics. Existing first-run.ts lines 211/212/219 require an ES2024 Promise library; the configured library is ES2023. No unrelated baseline or .github edits.

Explicitly not fixed here — #4767

The executed current-guard source safety matrix on the product change had 8 passed / 8 failed / 0 skipped (diagnostic, not journey proof). Post-download revocation now blocks explicit renderer restart. These safety assertions still fail:

  • Activated managed signed-out, failed-policy GET, and cached-pending-policy automatic admission.
  • Revocation before manual download, during check, and during download.
  • Native automatic install-on-quit remains armed even after renderer blocks install; direct native install IPC still only checks activation.

Separate onboarding/branding staging and restart, native staging invalidation, and actual OS installation are not covered by this renderer fix. No native exploit or broader closure is claimed. Public/unmanaged and explicitly unrestricted controls still pass.

…g a downloaded update

A downloaded update stayed installable after the organization revoked its
version from allowedDesktopVersions. Refresh the desktop config before
bridge.installAndRestart() and re-run the allow decision on the downloaded
version; a revoked version is not installed and the update returns to the
blocked-by-policy state so the user can check again. An absent allowlist
still means unrestricted, and a failed refresh (offline) falls back to the
last known config instead of blocking on a network error.
@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 4:58am UTC
openwork-den Ignored Ignored Preview Sep 10, 2026 4:58am UTC
openwork-diagnostics Ignored Ignored Preview Sep 10, 2026 4:58am UTC
openwork-landing Ignored Ignored Preview Sep 10, 2026 4:58am UTC

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Warden review summary — Clear

Native findings: 0. 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 (42770 ms), confidentiality-review (72613 ms), spec-provenance-review (69019 ms), desktop-den-sync-review (76075 ms).

Blockers

  • None.

Advisories

  • None.

Needs recheck

  • None.

Observed review-thread metrics

  • Unique observed run attempts in retained window: 4
  • Distinct heads in retained window: 4
  • 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: 4/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 (eda8d6a9ce864b116501658d04e7247b800c5867). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Passed · 6/6 tests · 7/7 assertions · 5 images

Commit d5040026407c9b38d7c20328093cc7a5847d7013 · selected evidence

Open review report

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 (dfa81c7c965644e80c72789edfb1237dd5d01f86). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

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 (513e544c0a51b947d29542b138f725ca4b049aac). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@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 (d5040026407c9b38d7c20328093cc7a5847d7013). 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

Passed — explicit-install scope, final head d5040026407c9b38d7c20328093cc7a5847d7013

Three distinct journey cases passed on Daytona / engine v1, using two complementary name-filtered runs on the same committed source. Each command exited 0. The runner labels non-selected names as skipped; the union executes all three names, with no dependency skip. This is not a claim that the earlier unfiltered red runs passed.

Private Review publication failed: the available Blob credential belongs to a public store, while Review requires a private store. Text evidence fallback below; no screenshots/records were uploaded to a public Blob store. Reference screenshots are not installation proof. The two recorded visual expectations for the background case passed; the other screenshots have no visual expectations.

1. Downloaded version revoked before explicit restart — Passed

Source receipt: evals/results/test-runs/2026-09-10T05-09-08-745Z-a-downloaded-update-is-not-installed-once-the-organization-revokes-its-version/test-run.json

Recorded trace: real testkit Den → org PATCH /v1/org → signed-in desktop → Check now → allowed version downloads → see Ready to install: v9.9.9 → revoke through org API → Restart to update → Restart & update → see OpenWork 9.9.9 is available, but this installation is not eligible for it yet. → no Ready/Restart/Install controls.

Machine assertions: downloads: 1, installs: 0. Reapprove, Check now, download again, see ready and no blocked message, Install & restart; final downloads: 2, installs: 1. This counts calls at the fake installer boundary, not a real OS swap.

2. Background download, optional restart, failures and manual retries — Passed

Source receipt: evals/results/test-runs/2026-09-10T05-02-56-978Z-updates-download-outside-settings-and-offer-a-persistent-optional-restart/test-run.json

Recorded assertions cover interval/focus checks, no premature restart while downloading, two failed downloads, persistent titlebar readiness, Keep working without an install, and custom branding. The test then turns off Check automatically through the actual switch and asserts its persisted preference, isolating manual retry behavior from background checks after policy refresh. Two installer failures leave no restart affordance; fresh checks/downloads recover. Final confirmation: installAttempts: 3, installs: 1. Two visual expectations passed, zero pending.

3. Confirmed relaunch resumes only unfinished work — Passed

Source receipt: evals/results/test-runs/2026-09-10T05-13-07-605Z-a-confirmed-update-relaunch-resumes-only-the-unfinished-task-on-its-original-eng/test-run.json

Recorded assertions: restart through the titlebar confirmation; changed renderer time origin; continuation reply on the original engine; exactly one recovery marker/final provider response; stopped/completed histories unchanged; subsequent recovery ticks do not duplicate or restart excluded work. This exercises the existing relaunch witness, not a real updater bundle swap.

Reproduction commands

Common environment: OPENWORK_EVAL_REF=d5040026407c9b38d7c20328093cc7a5847d7013 OPENWORK_EVAL_DAYTONA=1 OPENWORK_WORLD_PLACE=daytona OPENWORK_EVAL_E2E_TESTS=1 (secrets injected with infisical run --silent --).

pnpm --dir evals exec vitest run --config vitest.config.ts --project e2e specs/background-desktop-update.e2e.test.ts -t 'updates download outside Settings'
# exit 0; 1 passed, 2 names filtered out
pnpm --dir evals exec vitest run --config vitest.config.ts --project e2e specs/background-desktop-update.e2e.test.ts -t 'revokes|a confirmed update'
# exit 0; 2 passed, 1 name filtered out
pnpm --filter @openwork/app typecheck
# exit 0
pnpm --dir apps/app exec bun test --isolate tests/electron-updater-install-policy.test.ts tests/version-gate.test.ts
# exit 0; 26 passed, 0 failed
pnpm --dir evals exec node --test packages/cdp/test/input.test.ts
# exit 0; 8 passed, 0 failed, 0 skipped

Earlier red receipts remain on disk: a witness check-count assumption, immediate dialog-dismissal assertion, manual/background retry race, missing switch locator support, and one recovery continuation timeout. The timeout is unresolved, not labeled pre-existing or fixed by this PR; recovery passed on two earlier heads and on the final head.

Final local Warden

infisical run --silent -- pnpm warden:check, exit 0. Clean committed scope: all six changed files. Expected and completed: diff-security-review, confidentiality-review, spec-provenance-review, desktop-den-sync-review. No finding IDs / no findings / no blockers. No suppressed findings or overrides.

Before and after: HEAD d5040026407c9b38d7c20328093cc7a5847d7013; origin/dev 79c15db59adb52de9ba83f81b473eb2b4e65291c. Run reference 51129ef0-2026-09-10T05-18-03-095Z; private analysis logs are not attached. Local review does not replace GitHub approval.

Remaining scope — NOT closed

The broader current-guard source matrix remains Failed: 8 passed / 8 failed / 0 skipped. Signed-out/failed/pending managed policy, pre-/mid-download revocation, and native quit/direct-install boundaries remain in same-owner follow-up #4767. The pure absent-allowlist semantics and public/unmanaged controls are preserved. No claim that all updater risks are closed.

@yomgui
yomgui merged commit 88b1eec into dev Sep 10, 2026
28 checks passed
yomgui added a commit that referenced this pull request Sep 11, 2026
Resolves evals/specs/background-desktop-update.e2e.test.ts after #4745 was
squash-merged to dev (a7748b2): keep this PR's version, which is a superset of
#4745 and #4761 and adds only its own step (automatic checks stay on through the
first failed install, asserted, then are switched off inside iteration 0). The
merged tree differs from dev in this spec only.
yomgui added a commit that referenced this pull request Sep 11, 2026
…to-check skip with automatic checks on (#4821)

* fix(app): close the restart prompt and command palette synchronously on dismiss

Base UI keeps a dialog popup mounted (and partially opaque) until its exit
animation or transition finishes, so the restart prompt and the command
palette stayed visible for 100-200 ms after Keep working / Escape. Hide the
popup with display:none as soon as it is closed; Base UI then unmounts it on
the next frame.

* fix(app): keep background update checks paused after an install fails

After a failed install the updater status is error/install, which the
automatic check treated like idle: the next focus/online/interval trigger
(or an effect re-run once the 15-minute window had passed) re-checked,
auto-downloaded the same update and left Settings' Check now disabled
behind "Downloading update…". The update is already downloaded, so a
background re-check cannot fix an installer failure; keep the failure and
let the person retry from Settings.

* test(evals): prove a failed install does not restart the background download loop

Return to the app after the check interval before retrying from Settings,
and assert Settings still shows the install failure with no new download.
Apply the custom branding only for the final confirmed restart: the eval's
dev-bridge branding does not survive the Den settings sync that opening
Settings performs for a signed-out app (the failure loop visits Settings).

* test(evals): exercise the error/install auto-check skip with automatic checks on

The first failed install and its returnToApp() now run with Check
automatically still on, so the counters staying at checks 6 / downloads 3
is observed against the updater's error/install guard rather than the
disabled switch. The switch is turned off right after, so the second
retry and the final install keep #4761's isolation.
benjaminshafii pushed a commit that referenced this pull request Sep 25, 2026
* fix(desktop): restore forced sign-in and version allowlist

#5131 suspended desktop feature-policy enforcement but also routed two
non-policy controls through the same switch:

- Required sign-in is a property of the enterprise and cloud builds
  (desktop-distribution.mjs); desktop-bootstrap.json can only raise it.
  The app shell ignored it on desktop, so activated enterprise installs
  opened local work without Den sign-in.
- allowedDesktopVersions is an organization setting (PATCH /v1/org), not a
  desktop policy. The runtime projection dropped it, so the updater and
  recovery picker stopped honouring the organization's version pin.

Restore both. Feature-policy toggles and execution rules stay suspended.
The updater again waits for the organization's desktop config before its
first check, and refreshFresh fetches instead of returning the cached
projection so the install-time re-check (#4761) sees a revoked version.

Specs: packaged-activated-launch expects the forced sign-in surface again;
background-desktop-update proves a revoked version is not installed and a
re-approved one is. Docs: the enterprise deployment page no longer claims
feature policies are enforced.

Signed-off-by: Benjamin Shafii <[email protected]>

* fix(desktop): keep update checks working when Den is unreachable

refreshFresh now always fetches the organization's desktop config, so a
failed fetch (offline, or an older or unavailable Den) would have failed
Check now and the alpha channel resolution. Fall back to the last known
config, matching the install re-check's existing offline rule.

Rename updatePolicyKnown to allowedVersionsKnown and split the MDM docs:
allowed desktop versions are an organization setting, not a desktop policy.

Signed-off-by: Benjamin Shafii <[email protected]>

* test(evals): expect the cloud build's sign-in gate on first launch

The cloud build requires sign-in again, so its packaged first launch shows
the sign-in surface (the contract before #5131) instead of the signed-out
task composer.

Signed-off-by: Benjamin Shafii <[email protected]>

---------

Signed-off-by: Benjamin Shafii <[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