|
| 1 | +# LevelCode — Signed auto-update (Squirrel `.zip`) — scope |
| 2 | + |
| 3 | +**Goal:** make the editor's built-in **Check for Updates…** actually install a new build, instead of |
| 4 | +always reporting "There are currently no updates available." |
| 5 | + |
| 6 | +**Today:** that dialog is *correct behaviour*, not a bug. `Api::UpdatesController` (thin.ly) serves |
| 7 | +**204** to every client except the notify-only extension — a deliberate **unsigned-build guard**, |
| 8 | +because the built-in Squirrel updater *auto-downloads and installs* whatever `url` a 200 returns, and |
| 9 | +today that `url` is a GitHub **release page**, not a signed `.zip`. Squirrel would download it and fail. |
| 10 | + |
| 11 | +Verified against production while scoping: |
| 12 | + |
| 13 | +| Client | Request | Response | |
| 14 | +|---|---|---| |
| 15 | +| Built-in Squirrel updater | `GET /api/update/darwin-arm64/stable/<commit>` | **204** (guard) | |
| 16 | +| Notify-only extension (`User-Agent: LevelCode Updater`) | same | **200** `productVersion: 0.7.2` | |
| 17 | + |
| 18 | +## What already exists (most of the hard part) |
| 19 | + |
| 20 | +- **`scripts/notarize.sh sign`** — Developer ID signing with **hardened runtime** + `levelcode.entitlements`. |
| 21 | +- **`scripts/notarize.sh notarize-app`** — notarizes **and staples the `.app` itself**, precisely so a |
| 22 | + copied-out app validates offline. **This is exactly the artifact Squirrel needs.** |
| 23 | +- **CI already zips an app** with `ditto -c -k --sequesterRsrc --keepParent` (for the UNSIGNED artifact) — |
| 24 | + the same command, applied to the *signed* app, produces the feed asset. |
| 25 | +- **`Api::UpdatesController`** already implements the full Code-OSS feed contract, the guard, and |
| 26 | + `LEVELCODE_UPDATE_FEED` (a JSON env override) — which doubles as the **rollback/pin lever**. |
| 27 | +- **`Levelcode::EditorReleaseFeed`** already resolves tag → commit, `product_version`, and timestamp. |
| 28 | + |
| 29 | +So this is **not** a new signing pipeline. It is: publish one more asset, teach the feed to point at it, |
| 30 | +then lift the guard. |
| 31 | + |
| 32 | +## The gap |
| 33 | + |
| 34 | +1. **Release artifact.** Produce `LevelCode-<arch>.app.zip` from the **signed + notarized + stapled** |
| 35 | + `.app` (a `ditto` after `make-dmg.sh`'s signing step) and publish it on the release. The `.dmg` stays — |
| 36 | + it remains the fresh-install path; the `.zip` is update-only. |
| 37 | + *The zip is the only new release asset.* `make-dmg.sh` also writes a `.app.zip.sha256` beside it, but |
| 38 | + that stays **local**: the feed's `sha256hash` comes from GitHub's API-computed asset `digest` |
| 39 | + (`"sha256:<hex>"`), so no sidecar is ever fetched. The file is for verifying by hand that the zip you |
| 40 | + published is the zip you built. |
| 41 | +2. **Feed asset resolution.** `EditorReleaseFeed#fetch_release` currently returns `url: rel["html_url"]` |
| 42 | + (the release page) and `sha256hash: nil`. It must select the **right asset** from `rel["assets"]` by |
| 43 | + arch and return its `browser_download_url` plus the hash from that asset's own `digest` field. |
| 44 | +3. **Arch mapping.** Feed targets are `darwin-arm64` and `darwin` (Intel). Map to the arm64 / x64 zips |
| 45 | + respectively — **never serve a cross-arch zip**. |
| 46 | +4. **Lift the guard.** Set `LEVELCODE_UPDATE_FEED_SIGNED=1` on Elastic Beanstalk — **only after 1–3**. |
| 47 | +5. **Notify-only Download button.** `extensions/levelcode-updater/extension.js:96` is |
| 48 | + `feed.url || product.downloadUrl || base`. Once `feed.url` is a raw `.zip`, that button would hand |
| 49 | + users a zip instead of the release page. Reorder to prefer `product.downloadUrl` / the release page. |
| 50 | + |
| 51 | +## Slices |
| 52 | + |
| 53 | +**S1 — publish the signed zip (client).** Add the `ditto` + `shasum` step to `make-dmg.sh` (or a |
| 54 | +`make-update-zip.sh`), update `docs/RELEASING.md`, and upload `LevelCode-<arch>.app.zip` with the dmg. |
| 55 | +*Ship this alone first — it is inert until the feed points at it.* |
| 56 | + |
| 57 | +**S2 — serve it (server).** Teach `EditorReleaseFeed` to pick the arch-matched asset + hash. Guard stays |
| 58 | +on, so behaviour is unchanged; assert the new shape in `spec/requests/api/updates_spec.rb`. |
| 59 | + |
| 60 | +**S3 — extension URL fix.** Reorder the Download preference so it never opens a raw zip. |
| 61 | + |
| 62 | +**S4 — flip the flag + verify.** Set `LEVELCODE_UPDATE_FEED_SIGNED=1`, then run the end-to-end test below. |
| 63 | + |
| 64 | +## Risks (the ones that actually bite) |
| 65 | + |
| 66 | +- **Sequencing.** Flipping the flag before S1–S2 makes things *worse* — Squirrel would download a web |
| 67 | + page and fail loudly. S4 must be last. |
| 68 | +- **Signing-identity continuity.** Squirrel.Mac refuses an update whose Developer ID doesn't match the |
| 69 | + running app. **Rotating or changing the signing cert breaks auto-update for every installed build**, |
| 70 | + with no in-app recovery — those users must re-download manually. Treat the identity as long-lived. |
| 71 | +- **No staged rollout.** Publishing a release auto-installs for everyone on the next check. The rollback |
| 72 | + lever is `LEVELCODE_UPDATE_FEED` (pin the previous commit) — but installs that already updated are |
| 73 | + *not* reverted. Consider a canary/percentage gate before this is a large install base. |
| 74 | +- **Unverifiable by inspection.** Auto-update can only be proven by actually doing it on a real Mac |
| 75 | + (install N, publish N+1, watch the swap). Budget a real test cycle, not a code review. |
| 76 | +- **Stapling must survive the zip.** `ditto --sequesterRsrc --keepParent` preserves the stapled ticket; |
| 77 | + re-zipping with `zip(1)` can drop extended attributes. Keep using `ditto`. |
| 78 | +- **Notarization latency.** Apple's notarization is minutes, occasionally longer — the zip must be cut |
| 79 | + *after* `notarize-app` completes, or you publish an unstapled app. |
| 80 | + |
| 81 | +## Exit test |
| 82 | + |
| 83 | +1. Install **N** (e.g. v0.7.2) from the dmg, confirm `About` shows its commit. |
| 84 | +2. Publish **N+1** with the signed zip attached and the feed serving it. |
| 85 | +3. In N: **Check for Updates…** → it offers, downloads, and **relaunches into N+1**; `About` shows the |
| 86 | + new commit. No Gatekeeper prompt. |
| 87 | +4. Confirm the Intel build receives the x64 zip (not arm64). |
| 88 | +5. Pin `LEVELCODE_UPDATE_FEED` back to N's commit → a fresh N+1 install reports "up to date" |
| 89 | + (proves the rollback lever). |
| 90 | + |
| 91 | +## Not doing (explicitly) |
| 92 | + |
| 93 | +- Windows/Linux feeds — `EditorReleaseFeed::TARGETS` is macOS-only by design; announcing a build that |
| 94 | + doesn't exist is worse than silence. |
| 95 | +- Delta updates. Full-zip replacement is fine at this size. |
| 96 | +- Auto-update for the notify-only extension — it stays notify-only by design. |
0 commit comments