# Installation and distribution implementation plan

The contracts implementation holds to. Design: [Installation and packaging](https://fzkuji.github.io/OpenProgram/docs/reference/design/distribution/installation-packaging.html). Update architecture: [Automatic updates](https://fzkuji.github.io/OpenProgram/docs/reference/design/distribution/automatic-updates.html). Windows: [Windows support](https://fzkuji.github.io/OpenProgram/docs/reference/design/distribution/windows-support.html).

## Product boundary

| Who | Gets | Never |
| --- | --- | --- |
| Ordinary users | Complete GitHub Release artifacts; the same capability set per platform and architecture | `pip install openprogram`, `pipx`, `uv tool install` or the PyPI page as a product entry; PyPI resolution, repository clone, npm build or first-use Chromium download at install |
| Developers | The complete product plus editable sources, tests, diagnostics, local frontend builds, and explicitly configured perception, OCR or browser overlays that own their model assets | Implicit installation of excluded dependencies |
| Release assembly, source checkouts, third-party extension environments | May build or install wheels | Presented as a user path |

**Where repair messages point**

| Surface | Points to |
| --- | --- |
| Site index, onboarding, troubleshooting, examples, runtime dependency errors | The formal installer or a complete reinstall |
| Missing PDF dependencies | A complete reinstall |
| Troubleshooting | Separates the managed private runtime from `uv run` or `.venv` source development |
| OpenClaw skill | Runs through `uv run --project` for its cloned checkout |

Out of scope: a Python-free rewrite, removing `pyproject.toml`, and changing plugin or third-party Program formats.

## Artifacts per platform

| Platform | CLI and server | Desktop |
| --- | --- | --- |
| macOS arm64, x86_64 | Runtime archive | DMG and ZIP; signed and notarized when Apple credentials exist, otherwise `-unsigned` |
| Linux x86_64, arm64 | Runtime archive, with Web UI and TUI | Thin deb and AppImage |
| Windows x64; arm64 behind a switch | Runtime archive | Thin NSIS installer; `-unsigned.exe` without a certificate |

| Item | Rule |
| --- | --- |
| macOS App | The byte-identical runtime archive; only the Electron shell differs |
| Windows and Linux Apps | A seed built from the same lock |
| Also in a release | Checksums, developer wheel and sdist files, `release-manifest.json` |
| Failed complete entry | The artifact is absent, never reduced |
| Development App, self-update | Re-sign with the local development certificate; the production signature is not preserved |

## Runtime contents

| Item | Contract |
| --- | --- |
| Capabilities | `web`, `providers`, `mcp`, `memory`, `channels`, `search`, `tui.ink`, `browser.playwright` |
| Pinned | CPython 3.12.10 and uv 0.11.16 in `scripts/release/product-runtime.json` |
| Programs | None bundled. Computer use is a built-in tool and needs no bundled model. |
| Rejected distributions | PyTorch, torchvision, OpenCV, EasyOCR, sentence-transformers, triton, `nvidia-*`, `cuda-*` |
| Host requirement | System Git for Session and Memory history; no launcher bundles Git |
| Excluded | OS credential-store integration; Chrome or Edge extension installation; distro-native deb or rpm packages |

**What `verify-product-runtime.py` checks**

- Launches a headless Chromium page; an artifact may record `browser_probe` as deferred only under `--allow-deferred-browser`. The terminal installer passes that flag on a Linux machine without Chromium's system libraries, so the launch waits for the browser tool's first use.
- Every launch asks for the full browser first, so macOS and Windows runtimes ship it alone; Linux also carries the headless shell, which needs fewer system libraries and is what starts on a bare server.
- While building (`--write`, `--probe-only`), reads every Mach-O and ELF file's load commands: a library loaded from outside the runtime and the system (a runner's Homebrew OpenSSL, say), or a macOS file needing a newer macOS than `macosMinimum`, fails the build. It parses the files itself, so it needs no `otool`.
- Imports channel and search dependencies; checks Web assets.
- Runs both built-in PDF extraction paths on a generated PDF; probes Rich rendering.
- Requires installed OpenProgram metadata to equal the runtime manifest version.
- Manifest schema 2 records each capability's `present` and `verified`, the product-manifest and lock hashes, exact distributions, platform and architecture.

## Release acceptance

Each target is built on its native runner, on tag push `v*` or manual dispatch for an existing tag.

1. Source, lockfile, Desktop and installer versions agree.
2. Runtime archives are assembled, archived and verified per platform and architecture.
3. Desktop jobs embed the same runtime, sign, and verify it before upload.
4. CLI installer jobs verify checksum, extraction, capabilities, worker cold start, atomic `current` activation and launcher version.
5. The publish job writes the release manifest and requires `.github/release-notes/<tag>.md`, in English, with the expected heading. It never overwrites a public release.

**Packaging facts each pipeline depends on**

| Fact | Handling |
| --- | --- |
| `semble` | `>=0.5.3`, whose `semble-grammars` publishes the native wheels every target needs |
| Wheel target | `build-base.sh` and `.ps1` install with `--only-binary :all:` and `--python-platform` for the oldest supported system (`macosMinimum` 13.5 through `MACOSX_DEPLOYMENT_TARGET`, `glibcMinimum` 2.35), never the runner's. `runtime-wheels.py check` proves from `uv.lock`, before any build, that each target has every wheel. The target is the packaging Python's own build, not the runner's machine: x64 Python on Windows on Arm and an x86_64 build under Rosetta install x86_64 wheels, and the bundled Git follows the same answer (`runtime-wheels.py target`) |
| Reused base | A base whose Python pin is unchanged is copied and brought to the new lock with `uv pip sync`, which takes the requirements file as an argument: the pinned uv refuses `--requirements` there, while `uv pip install` needs it. A component test runs both scripts' package step against that uv, offline, into a throwaway environment, and CI installs that uv. |
| Build profile | The self-update build runs with its own `HOME`, `USERPROFILE`, `LOCALAPPDATA` and `APPDATA`; without the last two PowerShell writes its module cache into the worktree, and the next build refuses it as uncommitted |
| Source builds | Only what `sourceBuilds` in `product-runtime.json` names, each against a static library its leg prepares: cryptography on Intel macOS (no x86_64 wheel; `prepare-macos-native-deps.sh` builds static OpenSSL with vcpkg for macOS 13.5) and four packages on Windows on Arm. A listed package that gains a wheel fails the check |
| Oldest macOS | 13.5, because Playwright's bundled Node needs it; the App's `LSMinimumSystemVersion` (electron-builder `minimumSystemVersion`) and the install page say the same, and the terminal installer refuses an older Mac with where to update |
| Intel macOS and torch | No patched torch wheel exists, so the `embedding` extra excludes that platform |
| Architecture names | Runtime archives use `x86_64`; electron-builder takes `x64` (`release-matrix.py`) |
| Runtime manifest | Formatted JSON; shell parsers tolerate whitespace |
| `pypdf`, `rich` | Locked base dependencies; an Ink startup failure enters the bundled Rich REPL |
| Packaged Electron | Resolves Python only from `process.resourcesPath` and runs `-I -B -m openprogram worker start`; no `PATH` fallback, no bytecode in the signed App |
| Wheel | Built after asset staging; holds `openprogram/interfaces/server/_frontend`, so it serves `/chat` without Node.js |
| Linux smoke | `linux-release-smoke.yml` runs by hand only, needs no signing or PyPI credentials and keeps artifacts in CI |

## Public installer

```
curl -fsSL https://fzkuji.github.io/OpenProgram/install | sh
```

| Part | Contract |
| --- | --- |
| Root script | Resolves the latest stable release, validates a three-part numeric version, downloads the immutable tagged installer and forwards the version. No second installer; checksum, capability and cold-start checks unchanged. |
| Pinning | `OPENPROGRAM_VERSION=X.Y.Z` on the `sh` process |
| Scripts | `scripts/install-release.sh` is the published compatibility URL; it downloads `scripts/release/install-release.sh` from the same tag |
| Publication | `docs/_static_root/install.sh` is renamed to the site root as `/install`; `/docs/install/` stays the documentation directory |

## Local App

| Part | Contract |
| --- | --- |
| Entry | `npm --prefix apps/desktop run dist` builds one complete temporary App, verifies it with the packaged-runtime smoke and replaces only `/Applications/OpenProgram.app` |
| Downgrade | `install-app.sh` rejects an older candidate before locking and again on the staged copy, before worker shutdown or file changes. Numeric segments compare as arbitrary-precision decimals; no override, no prerelease ordering. |
| Invalid App at the path | Preserved and rejected, never treated as absent |
| Failed activation | The old App's only copy is kept; a failure after Launch Services registration restores and re-registers it, keeping the original error |
| launchd | A genuine unload failure stops before App changes; a stale plist can be replaced |
| Concurrency | One per-user packaging lock across worktrees (`~/Library/Caches/OpenProgram/app-package.lock`); an atomic install lock in the target Applications directory. A competitor fails before any change. |
| Cleanup | Removes the random App directory, staged runtime, wheel build, Web output, copied frontend and lock; keeps App data, sources, dependencies and user state |
| Icon | `apps/desktop/build/AppIcon.icon` is the layered source: four 1024 x 1024 vector SVGs on a transparent canvas, one cell and three flat discs, no drawn outer shape. `icon.icns` is checked in as Electron's input. `check-icon.sh` enforces both. |

## Verification

On top of the [affected tests](https://fzkuji.github.io/OpenProgram/docs/reference/design/testing/test-system.html#full-run):

| Changed | Run |
| --- | --- |
| Release, install, refresh | `python -m pytest tests/component/config/test_distribution_release` |
| Desktop packaging | `python -m pytest tests/unit/webui/test_desktop_packaged_files.py`; `npm --prefix apps/desktop run check` |
| Web frontend serving | `python -m pytest tests/component/webui/runtime/test_webui_frontend.py`; `npm --prefix apps/web run check` |
| Documentation | `python -m scripts.docs_site.build`; `python -m scripts.docs_site.checklinks` |
| Shell scripts | `bash -n` on the changed scripts |
| Every change | `git diff --check` |
| Platform artifacts | Native release runners only: one host cannot validate another platform's runtime |
