# Automatic updates

A person installs OpenProgram once, from the installer of the latest `vX.Y.0`. Every later update arrives inside the App: a check shows **New** beside the sidebar wordmark; **Download update** downloads only the files that changed, builds and tries the new version; **Restart to update** switches to it.

Only a GitHub Release reaches Apps on the Stable channel; the daily sync of `main` reaches only the Preview channel.

1. **Publisher** This computer, no Actions: `publish-github.sh`, then `publish-updates.py run` builds the code layer, writes one pack of new objects and signs the pointers
2. **`updates` release** `channel.json` for announced releases, `latest.json` for every publish, each signed inside; packs of objects that never change
3. **Installed App** 30 s after start, then hourly: verify signature and sequence, show New. On Download update: read the changed layer trees; fetch missing objects as byte ranges; assemble, build, try; hold until Restart to update

## What is published

Everything sits on one rolling GitHub release of `Fzkuji/OpenProgram`, tag `updates`: a prerelease, never latest, not `v*`. Clients read it only through `https://github.com/Fzkuji/OpenProgram/releases/download/updates/<name>`, named in one place, `UPDATES_URL` in `official/channel.py`.

| File | Holds |
| --- | --- |
| `channel.json` | The newest announced release. What installed Apps read |
| `latest.json` | Every publish, daily syncs included. Read by an App on the Preview channel, and by the updater with `OPENPROGRAM_UPDATE_POINTER=latest` |
| `pack-<12 hex>.pack` | Objects back to back, no header, named by the start of its own sha256. Never changed once published |
| `runtime-<platform>-<base>.json` | A runtime layer the Release workflow built and uploaded with its pack, waiting for the publish that names it |
| `shell-<platform>-<version>.json` | The same for an App shell layer, uploaded by the Release workflow of the vX.Y.0 it belongs to |

**Pointer fields**

A pointer file is `{"signed": "<pointer JSON>", "signature": "<hex>"}`. The signed text holds `schema` (2), `pointer` (`channel` or `latest`, so one cannot be served as the other), `sequence`, `published_at`, `version` (three or four parts), `announce`, `build` (commit, 12 hex), `notes`, `commit`, `shell_compat`, `layers` (`{name: {manifest, pack, offset, length}}`; a shell layer adds the App `version`) and `packs` (`{name: {bytes, sha256}}`).

`channel.json` must have `announce` true. `sequence` only grows, across both pointers. The signature is hex Ed25519 over the signed text, with a key in `RELEASE_PUBLIC_KEYS` (`official/signing.py`; the same key in `update-service.js`).

## Format

| Unit | What it is |
| --- | --- |
| Object | One file's bytes, named by their sha256, stored as an independent zstd frame (level 19) |
| Pieces | A file of 1 MiB or more is published as 256 KiB pieces at fixed offsets, each piece an object. A re-signed binary changes only its header and its signature at the end, so the pieces between keep their names |
| Pack | Objects one after another. A publish writes at most one pack per changed layer, its trees last; where each object is lives in the trees |
| Tree | One directory, Git style, itself an object named by its sha256: `{"entries": [...]}`, each a file `{name, mode, size, sha256, at}` (a file in pieces lists `chunks: [[sha256, size, at], ...]` instead of `at`), a link `{name, symlink}` or a directory `{name, tree, at}`. `at` is `[pack, offset, length]`, with `""` for the pack the tree itself is in. Code sources also carry their Git blob id |
| Layer format | `schema` 3 in the root tree. A client refuses a layer in another format by name. The publisher writes the code layer whole again and refuses until the runtime and shell layers are rebuilt |
| Layer manifest | The root tree, which also holds `schema`, `layer` and `meta`. A directory whose contents did not change keeps its tree, so a client reads only the trees on the path to a change |

| Layer | Contents | Meta |
| --- | --- | --- |
| `code` | Every platform. The commit's whole tracked tree under `source/`, and the built Web, docs and terminal bundle under `frontend/` | Commit, Git tree, version, base id, `shell_compat` |
| `runtime-<platform>` | The base: Python and locked packages, Playwright, Node, Git, uv, and the Tailscale sidecar in `bin/` | Base id, platform |
| `shell-<platform>` | macOS arm64 and x86_64, Windows x86_64, Linux x86_64 and arm64: the App exactly as built, signed and notarized: `OpenProgram.app`, the install folder, or the AppImage as one file, with modes and links | Platform, App version, executable, `shell_compat` range, Python minor, empty directories |

- No extended attributes: a macOS bundle's signature lives in its Mach-O files, `_CodeSignature` and the stapled ticket, all ordinary files. The client clears any attribute before checking.
- A deb keeps its installer: it sits under `/opt`, which only root writes.
- The shell changes only with a feature release, which always carries a new commit too. The client still compares the shell layer itself, so an App that took the code when it could not replace itself takes the shell later.

The base id hashes `uv.lock`, the pyproject dependencies, `product-runtime.json` and the Git tree id of `apps/tailnet`, left out when the commit has no such tree.

## On an installed App

| Step | Rule |
| --- | --- |
| Channel | **Stable** (default) reads `channel.json`, announced releases only. **Preview** reads `latest.json`, every publish, and runs the updater with `OPENPROGRAM_UPDATE_POINTER=latest`; a publish that is not a release shows as `X.Y.Z Preview <build>`. Switching checks at once; the highest sequence seen is kept, so Stable offers nothing until a release passes it, as Chrome's Beta to Stable |
| Check | About 30 s after start, then every hour, a failed check included. `update-service.js` reads the channel's pointer; a check only finds the update and shows it. **Download update** runs `openprogram upgrade --prepare --json`, which does the rest |
| Pointer | Signature over the signed text first. A sequence lower than the highest already seen (`<runtime>/channel-seen.json`) is refused, so a replayed old pointer cannot take the App back. A missing pointer, caught between the delete and the upload that replace it, means nothing new this check, without a message; the next hourly check finds it |
| Trees | The code layer's, and this platform's runtime layer's only when its base is new here. A tree already held here is not fetched again. A tree is capped at 16 MiB A tree or file in a pack the pointer does not list is refused: a pointer lists every pack its layers' files and trees are in, reused ones in older packs too, and those are the packs garbage collection keeps |
| App shell | On an App that can replace itself (not translocated, its folder writable, a Developer ID team on macOS, an AppImage rather than a deb on Linux), the shell layer for this computer is read when its version is newer than the running App's (`OPENPROGRAM_SHELL_VERSION`), also when the code is already here |
| Who decides | Whether the App can replace itself is decided here alone: every`upgrade --json` report carries `shell_swap`, and the App keeps the answer, so one that cannot gets the installer at every check |
| Code that needs the new shell | Runs only in the new App. A plain `upgrade` stops once the App is staged (`prepared`); only `upgrade --prepare` builds and tries it with the staged shell counted as installed, and a held update is not switched to while the installed shell cannot host it. The new App switches to it on its first start |
| Nothing to do | `up_to_date` when this repository already holds the published commit. `waiting_for_shell` when neither the shell nor a shell layer for this computer can host it; `waiting_for_runtime` when this platform's runtime is not published. Neither changes anything |
| What is missing | Source files whose Git blob the repository lacks; frontend and runtime files not already present at the same path and size in the running version or base, which are adopted after hashing; shell files not at the same path and size in the running App |
| A file in pieces | Only the pieces its earlier version here (same path, any size) lacks at the same offset are fetched. The pieces are joined in the object store, the whole file's sha256 is checked, and the pieces are dropped |
| Fetch | HTTP Range requests on each pack's download URL. GitHub redirects to a CDN that honours Range; the redirect is followed once per pack, each hop host-checked. Ranges closer than 64 KiB merge, at most 32 requests per pack, 6 in parallel. An interrupted download resumes from the objects already kept in `<runtime>/objects/` |
| Limits | Each response is capped at its range's size; a server that answers with anything but 206 is not asked again, and only dropped connections, 429, 5xx, codes past 599 that a local proxy invents, and expired CDN addresses are retried. Each object decompresses through a stream capped at the size its tree gives, whatever the frame claims, and is checked by its sha256 |
| Assemble | Under the update controller. The base is written from the runtime layer (a copy-on-write clone where the filesystem has one, else a copy). Missing blobs are written into Git, the tree is rebuilt with a temporary index and must equal the published tree id, then committed on `refs/heads/release` with fixed metadata; `refs/openprogram/official/<github sha>` maps it to GitHub's commit |
| New App | Before the trial, assembled in a hidden folder beside the App, `.<App name>.update/`, on the App's own drive whatever drive the data is on: links recreated, files from the store or copied from the running App and hashed, the Windows uninstaller carried over |
| Its check | macOS `codesign --verify --deep --strict`, the running App's team and version; Windows Authenticode from the running App's subject, or `NotSigned` on an unsigned App; Linux an executable ELF file. Then moved to `staged/` there and recorded in `<runtime>/shell/staged.json`; a failure changes nothing |
| Links | Resolved against the tree and refused if they lead out of it, also when only part of a layer is written |
| Build | The version is built from that commit with the prebuilt frontend, so no Web build runs. `version.json` records `official: {commit, sequence, code_layer}` |
| Finish | Replay, trial, hold or switch, rollback, below. Objects the current layers do not use are pruned after success; shell files are not kept as objects, only its trees |
| Restart with a new shell | Restart to update quits the App; a detached script (`sh`, PowerShell on Windows) waits for it to exit, swaps the App with two renames on one drive, the first undone if the second fails, and opens it. Only after a swap, each in its own try, on Windows it sets the uninstall entry's `DisplayVersion` (HKCU, by `InstallLocation`). After a swap it leaves `shell/activate` with the update's key; the new App switches to the prepared version as it starts |

`openprogram upgrade --from DIR` reads the same files from a local copy (`channel.json` and the packs). `upgrade --check --json` reports `published_days_ago`, for information; the text output notes a pointer older than 60 days.

## Replay, trial and switch

An installation on the version store carries the owner's own commits over to each new official commit.

| Part | Rule |
| --- | --- |
| Official line | One local commit per update taken, on `refs/heads/release`. It needs no GitHub history: only the new official commit and the commits on `local` it does not contain |
| Replay | The owner's commits are `release..local`. Oldest first, each is cherry-picked in `work/official-<release>`. A conflict is saved to `unreplayable/<release>/` and the others continue. A commit the release already has is skipped. The candidate builds on the official version, so an untouched Web bundle is cloned |
| Failure | A build or trial failure saves the newest commit and tries the rest, at most 5 retries before going straight to the unmodified official version. Lack of disk drops nothing. A failed switch does not retry |
| Prepare, then restart | The App's **Download update** runs `openprogram upgrade --prepare --json`. It downloads, builds and tries the candidate, then stops it in `ready` marked `held` with its target, so the App shows **Restart to update** and nothing switches. A check never downloads: the person starts the download. No worker start, watchdog or queue moves a held update. The restart shows a picture of the main window until the new UI loads (`update-snapshot.jpg`) |
| Held update | Preparing the same target again does nothing; a newer target cancels the held one first. The next `upgrade --json` switches to the held update (outcome `activated`) while it is still what would be installed, offline too; if `local` moved since, it is cancelled and installed the usual way. Any other update that needs the slot, including the `self_update` tool, cancels it first. `upgrade --check --json` names it under `prepared` |

## Publishing

No GitHub Actions run for code. `scripts/publishing/publish-github.sh` syncs `dev` to `main` as one squashed commit ([GitHub publishing](https://openprogram.io/docs/reference/design/distribution/github-publishing.html)), then runs `scripts/release/publish-updates.py run`.

1. **Read** The live pointers, over the download URL
2. **Build** The code layer, here. The frontend is built in the publisher's own version store and reused when unchanged
3. **Pack** The new objects into one pack. Each platform in `RUNTIME_PLATFORMS` (macOS arm64 and x86_64, Linux x86_64 and arm64, Windows x86_64) needs a runtime layer for the code's base id: a live one, one the Release workflow uploaded, or one built here
   
   Any platform missing: refused, nothing published. The refusal names the platforms and `gh workflow run release.yml -R Fzkuji/OpenProgram --ref main -f runtime_layers_only=true`
4. **Upload** New packs, then each pointer in one delete and one upload. A pointer carries its signature, so a reader sees the old one, none, or the new one. A pointer the release lost is put back from the publisher's local history

| Command | Does |
| --- | --- |
| `publish-updates.py plan` | Says what publishing a commit would do; exit 3 when refused. `publish-github.sh` runs it before pushing |
| `publish-updates.py run` | Publishes `latest.json`; with `--release vX.Y.Z` also `channel.json` |
| `publish-updates.py announce vX.Y.0` | Announces a feature release in `channel.json`. Refused until the vX.Y.0 GitHub Release is published, every runtime layer exists, and a shell layer of that version exists for every App the Release published that replaces itself (read from its `release-manifest.json`) and hosts both the new code and the code announced before it. A platform without one, such as a failed AppImage, keeps the installer |
| `publish-updates.py upload-runtime-layer` | The Release workflow's step, per platform: builds a runtime layer from a base and uploads its pack and `runtime-<platform>-<base>.json`. Moves no pointer and needs no key |
| `publish-updates.py upload-shell-layer` | The Release workflow's step for each signed macOS App, the Windows App and each AppImage (with `--seed`, which names its Python line): builds the shell layer from the App as users install it and uploads its pack and `shell-<platform>-<version>.json`. With `--no-upload`, as in a rehearsal, it only builds |
| `publish-updates.py build-runtime-layer` | Turns an existing base directory into a runtime layer here, published with the next run |
| `publish-updates.py release-page` | Creates a code-only release's GitHub Release page in one API call |
| `publish-updates.py gc` | Deletes packs nothing may still read; repacks when the live packs are mostly dead. A pointer that cannot be read is fixed from history, but only a 404 counts as missing: any other failure to reach the release stops the run |

A daily publish makes about 5 GitHub calls: one read of the release and its assets, one pack upload, a delete and an upload for `latest.json`, and the deletes of dead packs.

## What notifies people

| Publish | Effect |
| --- | --- |
| Daily sync (no `--tag`) | Moves `latest.json` only. Only Apps on Preview see it |
| Feature release (`--tag vX.Y.0`) | `publish-github.sh` pushes `main` and the tag and dispatches the Release workflow only (after its rehearsal and the 12 h wait). The workflow builds the installers, every runtime layer and every shell layer. Then `publish-updates.py announce vX.Y.0` announces it, so `channel.json` moves last. The only kind that may change the runtime or the shell |
| Code-only release (`--tag vX.Y.Z`, `vX.Y.Z.W`) | No workflow. The publisher updates `channel.json`, pushes the tag, which triggers nothing, and creates the Release page with the notes, not marked latest, linking the X.Y.0 installers. Refused when runtime or shell inputs changed: `this needs a feature release vX.Y.0 (runtime/shell changed)` |

`release.yml` runs only by `workflow_dispatch`. With `runtime_layers_only` it builds and uploads just the runtime layers.

## Garbage collection

A pack is kept while the live `latest.json`, the live `channel.json`, one of the last 3 pointers in the publisher's history, or a runtime layer waiting to be published (built here, or an uploaded `runtime-*.json`) names it; any other is deleted.

When over half the live pack bytes are used by neither pointer's layers, trees included, `gc` repacks what they use into one new pack. Storage stays bounded and there are no delta chains.

## Measured

| Case | Size |
| --- | --- |
| Code layer, first publish | 9,106 files, 170 MB raw; pack 59 MB |
| A one-line Python change | New pack 9.5 KB: 5 trees, 5.8 KB with a 330 B root, and the 3.7 KB file. A client downloads about 11 KB with the pointer |
| A re-signed macOS shell, same code | The signed 1.5.1 App (1,463 MB, 18,878 files) against a copy with all 305 Mach-O files and 15 bundles re-signed: 168 files differ. As whole files that is 929 MB, 291 MB compressed |
| The same, in pieces | 21 MB compressed (60 MB raw): 7 MB for 119 changed files under 1 MiB, 14 MB for the pieces of 49 larger ones. The Electron and Chromium frameworks drop from 73 MB to 3 MB |
| The cost of pieces | A file that changed throughout compresses larger in pieces: Electron Framework 66.5 MB whole, 78.1 MB in 256 KiB pieces, 73.7 MB in 1 MiB pieces. 1 MiB pieces from 4 MiB leave 47 MB for the re-signed shell, since 29 changed files of 1 to 4 MiB stay whole |

With one flat manifest the same change cost a client about 644 KB; per-directory trees, as in Git and OSTree's dirtree objects, leave only the path to the change.

**Why it works this way**

| Decision | Reason |
| --- | --- |
| Files named by their hash | As [OSTree](https://ostreedev.github.io/ostree/) and Steam depots do: a file any version already has is never fetched again, whichever version a client skips from |
| The source tree, not a Git bundle | A bundle needs a prerequisite commit a client may lack after skipping updates. The tree with blob ids lets any client rebuild the exact published tree from the blobs it has |
| No delta chains | Codex's desktop App (Sparkle) caps delta chains at 5. Content addressing plus repacking needs none |
| A signed static pointer | As Claude Code's signed manifest and magpie's signed checksum list: one small file decides what is trusted, and the sequence stops a replay |
| Download URL, not the API | GitHub's REST API allows 60 unauthenticated requests an hour, shared per IP. Release downloads have no such limit and honour HTTP Range |
| Code built locally, runtimes in CI | GitHub activity stays at the daily push and a few uploads; a full CI release build takes about an hour, so CI runs only when a runtime changes. Each platform's runtime needs that platform to build it |
| Refuse, not degrade | A new runtime or shell needs native files only a feature release carries; refusing keeps every install on something it can run |
| The App as a layer, swapped on restart | The way Chrome and Sparkle's delta updates reach the same bundle: the signed App is the unit, files the running App already has are reused, and the swap is two renames while the App is closed. The signature is checked on the assembled copy, so a fault in assembly cannot reach the user |

## Installers

Installers still carry the whole product. An App or terminal install without a version store updates from the latest stable GitHub Release this way, and a version-store App that cannot replace itself (a deb, a read-only or translocated App) takes the App file from it when its update needs a newer shell.

1. **GitHub latest** Non-draft, non-prerelease, `vX.Y.Z`
2. **Release gate** Unique assets
3. **Manifest gate** Version, bytes, SHA-256
4. **Desktop** No version store; a deb, or an App that cannot replace itself, when the shell changes Select the exact installer; stream to a resumable `.part` file; verify bytes and SHA-256; on Windows check Authenticode for this App's line; prepare it and offer Restart to update, or open the installer where the App cannot replace itself
5. **Managed CLI and server** macOS, Linux, Windows Fetch the installer from the immutable tag; verify archive and capability manifest; version probe and isolated worker cold start; macOS, Linux: switch `current`; Windows: replace launchers; the user restarts a running worker

| Install type | Path |
| --- | --- |
| `managed_release` | The route above. Immutable markers take precedence |
| `source_checkout` | Explicit Git ref: preflight, checkout, dependencies and build, probe, restart. Never shown as a stable Release |
| `unknown` | Stable error pointing to the official installer or a source checkout. PyPI, binary and Git paths are not guessed |

`openprogram upgrade` applies; `--check` reports current and latest read-only; `--dry-run` prints the plan. `pip_wheel` is not an install type: developer wheels are build inputs only.

## Desktop installers

| Platform | Asset |
| --- | --- |
| macOS, Windows, AppImage | A version-store App that can replace itself takes a new shell from its shell layer ([above](#client)), not from an installer |
| macOS, otherwise | An App without a version store, a local build (no team), a translocated or read-only App: `-mac-<arch>.dmg`, then `-unsigned.dmg`, saved where the user picks |
| Windows, otherwise | An App that cannot replace itself: `OpenProgram-<version>-win-<arch>.exe`, or `-unsigned.exe` on an App built unsigned, downloaded, checked and opened for the user |
| Linux deb | Only when the release needs a newer shell. The App sits under `/opt`, which it cannot write, so it replaces nothing itself: the `.deb` is saved where the user picks and opened with the system's package installer, which asks for the administrator password |
| Linux AppImage, otherwise | In a folder it cannot write: the `.AppImage` is saved where the user picks |

## Settings → Versions and Updates → Application

| State | Shows |
| --- | --- |
| Not checked | Cache absent or expired. Automatic checks default on |
| Checking | All windows share one in-flight Promise. Check button disabled |
| Up to date | Same or lower version. Stable downgrades are not offered |
| Update available | Version, date, plain-text notes summary. Full notes open only the fixed GitHub Release page |
| Downloading | Bytes and percent, published at most every 250 ms, with a guaranteed final state |
| Ready | Downloaded, checked and prepared; `readyVersion` names it. Settings shows **Restart to update**, the sidebar shows **New** beside the wordmark with the same action and the release page, and the App menu (File on Windows and Linux) gets **Restart to Update to X**. The menu says when a task is running, since the new App restarts the worker. A later check of the same release keeps it ready |
| Retryable error | Keeps verified release metadata, so retry needs no new check. `errorKind` is `rate-limited`, `network` or `failed` |
| Not published | A newer release exists with no file for this computer. The current App keeps working |

Plain Web shows the CLI instruction instead.

## Scheduling

Automatic checks discover; on an App that can replace itself they also download and prepare the release, at start too for one found before the last quit. Nothing is installed until the user restarts. Manual checks always refresh. Development mode does not check automatically.

| When | Next check |
| --- | --- |
| App start (packaged) | 30 s later |
| After that | Every hour, whether the last check succeeded or failed. Skipped while automatic checks are off |
| Check now | Checks at once; the hourly timer is unchanged |

**`update-state.json`**

Schema 1. Holds `automaticChecks`, `lastAttemptAt`, `lastSuccessAt` and the latest verified release metadata. Written with a temporary file and rename; POSIX sets the mode, Windows inherits the user-directory ACL.

Invalid JSON, unknown schemas, future timestamps, version or architecture mismatches and missing releases are normalized and rewritten. A write failure must not leave hidden in-memory setting changes.

## Trust boundaries

| Boundary | Rule |
| --- | --- |
| GitHub responses | Untrusted. HTTPS, fixed hosts, at most 5 redirects validated per hop, size limit, 30 s request timeout, 60 s download idle timeout. Requires `draft === false`, `prerelease === false`, tag `vX.Y.Z`, unique asset names and manifest basenames, GitHub size equal to manifest bytes. |
| Network path | Chromium's network stack, so the system proxy applies. On API 403, 429, 5xx or no answer: the `releases/latest` redirect plus `release-manifest.json`. If that fails too, an optional `update-source.json`, only with an Ed25519 signature from a built-in key |
| Renderer IPC | Exposes only state, check, boolean settings, download, open release, subscribe. Accepts no URL, path, hash, repository or command. Public state strips asset name, URL and SHA-256. Closing a window aborts nothing |
| Downloaded files | Random exclusive temporary files, short writes handled, deleted on any mismatch. CLI verifies in a new version directory and rejects archive path traversal. A launcher failure keeps the old `current` |
| New App shell | Its files are named by hash in a layer the pointer's signature covers. The assembled App must also pass the platform's own check before it is staged: on macOS `codesign --verify --deep --strict` and the running App's team, on Windows Authenticode from the running App's subject. The swap script takes a path only from `staged.json`, inside the App's own `.<App name>.update/staged/` |
| Signed Windows line | A signed App accepts only an installer with a valid Authenticode signature from its own publisher: the same certificate, or the same subject after a renewal. The publisher comes from the App's own file. If that read failed or timed out, or the App's signature is damaged, it is read again before the comparison; with no publisher known, the installer is refused |
| Unsigned Windows line | An App built unsigned accepts an installer that is `NotSigned` and matches the size and SHA-256 in `release-manifest.json`. That catches a damaged, truncated or substituted download. It does not prove the publisher: the manifest is unsigned and trusted through HTTPS to the fixed hosts, so whoever can publish a release there can publish an installer. A signed App never takes this line |
| What the update signature covers | The signature inside `channel.json` covers the pointer, which names every layer manifest and pack by hash, so it covers every object a version-store update takes. That includes shell layers. It does not cover App installers or `release-manifest.json` |
| Installer child process | Pinned repository and version. Allowed environment only: PATH, HOME, temp, locale, proxy, XDG, OpenProgram state. No provider or API credentials, no archive or checksum overrides. `--json` emits one JSON document |

## Failures

| What happened | Result |
| --- | --- |
| Offline, timeout, rate limit | Falls back to the web route first. Automatic: tried again at the next hourly check. Manual: retryable error with a plain reason. The App keeps running |
| Invalid Release or manifest | Rejected before download. No fallback to a wheel, source archive, other architecture or older version. The last valid metadata may stay |
| Stall, size, hash or Windows signature error | A dropped download retries and resumes through its `.part` file, across restarts. A size, hash or signature mismatch deletes the file and restores retry. An unverified file is never opened |
| CLI archive, cold start or launcher failure | Non-zero exit before the final switch. The previous version stays selected (`current` on macOS and Linux, launchers on Windows) |
| Switch done, worker still old | The command says so and prints the restart instruction. Running requests are not interrupted |

**References**

| Reference | Use |
| --- | --- |
| [GitHub Releases API](https://docs.github.com/en/rest/releases/releases#get-the-latest-release) | Adopted for metadata, notes and assets; clients still validate independently |
| [Electron update lifecycle](https://www.electronjs.org/docs/latest/tutorial/updates) | Adapted: check, available, download, ready, restart to install, error |
| [Electron `autoUpdater`](https://www.electronjs.org/docs/latest/api/auto-updater/) | Not used. No built-in Linux updater, and the swap it does on macOS (Squirrel) is a few lines here, held to the manifest's hash and the running App's team |
| [`electron-updater`](https://www.electron.build/docs/features/auto-update/) | Not used. No new updater package: Electron, Node, Python and shell cover it |

**Code**

| File | Holds |
| --- | --- |
| [`update-service.js`](https://github.com/Fzkuji/OpenProgram/blob/main/apps/desktop/main/self-update/update-service.js) | Metadata, state, cache, scheduling, asset selection, download, hash, public projection |
| [`app-replace.js`](https://github.com/Fzkuji/OpenProgram/blob/main/apps/desktop/main/self-update/app-replace.js) | Replacing the App on restart: the swap of a staged App shell, the Windows uninstall entry's version |
| [`windows-signature.js`](https://github.com/Fzkuji/OpenProgram/blob/main/apps/desktop/main/self-update/windows-signature.js) | Authenticode status, subject, thumbprint |
| [`apps/desktop/main.js`](https://github.com/Fzkuji/OpenProgram/blob/main/apps/desktop/main.js) | Timer, resume, IPC, multi-window broadcast |
| [`main/preload.js`](https://github.com/Fzkuji/OpenProgram/blob/main/apps/desktop/main/preload.js) | Fixed renderer bridge |
| [`general-section.tsx`](https://github.com/Fzkuji/OpenProgram/blob/main/apps/web/components/settings/sections/general-section.tsx) | Settings states and Web fallback |
| [`update-badge.tsx`](https://github.com/Fzkuji/OpenProgram/blob/main/apps/web/components/sidebar/update-badge.tsx) | New beside the wordmark once an update is found: Download update, then Restart to update |
| [`commands/updates/upgrade.py`](https://github.com/Fzkuji/OpenProgram/blob/main/openprogram/interfaces/cli/commands/updates/upgrade.py) | Install-type routing, Release gate, dry-run, JSON, installer execution |
| [`github_release/github.py`](https://github.com/Fzkuji/OpenProgram/blob/main/openprogram/operations/self_update/github_release/github.py) | Stable metadata, manifest, immutable installer retrieval |
| [`scripts/install-release.sh`](https://github.com/Fzkuji/OpenProgram/blob/main/scripts/install-release.sh), [`.ps1`](https://github.com/Fzkuji/OpenProgram/blob/main/scripts/install-release.ps1) | Published compatibility entry points; fetch the real installer from the same tag |
| [`scripts/release/install-release.sh`](https://github.com/Fzkuji/OpenProgram/blob/main/scripts/release/install-release.sh), [`.ps1`](https://github.com/Fzkuji/OpenProgram/blob/main/scripts/release/install-release.ps1) | Download, verify, cold start, launcher staging, atomic activation |
| [`official/replay.py`](https://github.com/Fzkuji/OpenProgram/blob/main/openprogram/operations/self_update/official/replay.py) | Replays the owner's commits onto a verified release and drops them on failure |
| [`official/channel.py`](https://github.com/Fzkuji/OpenProgram/blob/main/openprogram/operations/self_update/official/channel.py) | Pointers, signature and sequence checks, the download URL, byte-range transport |
| [`official/objects.py`](https://github.com/Fzkuji/OpenProgram/blob/main/openprogram/operations/self_update/official/objects.py) | Objects, packs, layer trees, the local object store |
| [`official/assemble.py`](https://github.com/Fzkuji/OpenProgram/blob/main/openprogram/operations/self_update/official/assemble.py) | What this machine lacks; base, source commit, frontend and the new App from the layers |
| [`official/shell.py`](https://github.com/Fzkuji/OpenProgram/blob/main/openprogram/operations/self_update/official/shell.py) | The running App, the staged App and its record, the signature checks |
| [`official/fetch.py`](https://github.com/Fzkuji/OpenProgram/blob/main/openprogram/operations/self_update/official/fetch.py) | What `openprogram upgrade` does on a version store: read, fetch, apply |
| [`official/publish.py`](https://github.com/Fzkuji/OpenProgram/blob/main/openprogram/operations/self_update/official/publish.py) | Code, runtime and shell layers, refusals, GC and repack |
| [`publish-updates.py`](https://github.com/Fzkuji/OpenProgram/blob/main/scripts/release/publish-updates.py) | The publisher: signing and the GitHub calls; run by `publish-github.sh` |
| [`release.yml`](https://github.com/Fzkuji/OpenProgram/blob/main/.github/workflows/release.yml) | Artifact publication and the latest-endpoint gate |

## Implementation status

| Part | Status |
| --- | --- |
| Layered updates | Implemented: format with per-directory trees, publisher, runtime layers from the Release workflow, client, GC and repack, the hourly `channel.json` check and the release rules. `pytest -q tests/unit/self_update/official/test_update_format.py tests/component/self_update/official/test_updates.py` |
| Prepare and restart | Implemented. `pytest -q tests/component/self_update/official/test_prepare.py` |
| Desktop and managed CLI installer routes | Implemented. `npm run check --workspace apps/desktop`; `pytest tests/component/config/test_formal_release_updates.py tests/component/config/test_distribution_release`. Windows and Linux routes are tested with stand-ins |
| Phase 2: shell layer | Implemented for macOS, Windows x86_64 and the Linux AppImage; tested with stand-ins: a fake bundle and AppImage, assembly from the running App's files, a shell newer than code already here, the staging check, the swap scripts and order, announce's refusal. `pytest -q tests/component/self_update/official/test_updates.py`; `npm run check --workspace apps/desktop`. Not yet run on a real signed install, in a Release workflow run, or with the Windows registry |
| Phase 3: installers from layers | Not built. Installers would be assembled from the published layers |
| Installed client | Open: a real install of a published release taking updates over GitHub, long runs and sleep, a real proxy, Authenticode with a real certificate, a shell swap on a real macOS and Windows App |
| Upgrading from v0.6.6 or earlier | No updater before v0.7.0: install the current DMG once by hand. CLI and server rerun the public installer once |

Out of scope: Windows sandboxing, PyPI product installation, replacing a running App while it runs: the switch happens only on Restart to update.
