# Developer ID distribution

## From checkout to release

1. A reviewed checkout builds an unsigned staging App: `electron-builder --mac --dir`, with `identity: null`.
2. `sign-macos-release.py` signs Mach-O files and nested bundles inside out with one Developer ID, with hardened runtime and secure timestamp. Mach-O files inside packed `.tar.gz` and `.zip` resources are signed too.
3. `codesign --verify --deep --strict` checks the whole signature.
4. `notarytool` notarizes the App. `stapler` staples it. `spctl --assess` accepts it.
5. ZIP and DMG are created. The DMG is signed, notarized and stapled.
6. Packaged-runtime smoke, checksums, upload.

Any failed command aborts the release. The signer never disables Gatekeeper or changes certificate trust, and refuses to sign `/Applications/OpenProgram.app`.

| Item | Rule |
| --- | --- |
| Artifacts | `OpenProgram-<version>-mac-<arch>.dmg` and `.zip`, arch `arm64` or `x64` |
| Updater | Prefers the signed name; still selects `-unsigned.dmg` for older releases |
| Notarization wait | 45 minutes. A timeout does not cancel the submission: the signer reads the status, and only `Accepted` continues |
| Local signing | Dedicated keychain and a validated `notarytool` profile |
| CI signing | Temporary keychain removed on exit. Secrets `MAC_CSC_LINK`, `MAC_CSC_KEY_PASSWORD`, `APPLE_ID`, `APPLE_APP_SPECIFIC_PASSWORD`, `APPLE_TEAM_ID`; variable `MAC_SIGNING_IDENTITY` |
| Missing credentials | No production artifacts |
| In build output | Only the public certificate identity. Keys and credentials stay out of the repository |
| Local source builds | A separate development identity. Source updates must not silently replace an installed production identity |
| Thin App helper | A second signed bundle, `Contents/Resources/seed/helper/OpenProgram.app`, identifier `ai.openprogram.runtime`. It has library validation off, because libpython lives outside its bundle (`entitlements.mac.helper.plist`), and so does every binary signed with `entitlements.mac.inherit.plist`, because compiled packages built on the user's machine are only ever ad-hoc signed. Privacy grants attach to its one path and signature, so a version switch leaves them in place. Binaries in a base are signed once, before the seed is packed |
| Full App Worker | The embedded runtime's Python and its named helper (`python` and `worker_python` in `runtime-manifest.json`) are signed with `entitlements.mac.helper.plist`: library validation off, the App's other grants kept. A Program's compiled dependencies and semantic memory's torch are installed after signing and carry no Developer ID, and a validating Worker refused them |
| What that costs | The Electron app and every other executable keep library validation on, and the hardened runtime still ignores `DYLD_*` variables, so the cost is this: code that can write to the user's OpenProgram folders can run inside the Worker with its privacy grants. The thin App's helper makes the same trade. The packaged-runtime smoke imports an ad-hoc-signed module through the signed Python after notarization |
| Windows | Authenticode, separate: [Windows support](https://fzkuji.github.io/OpenProgram/docs/reference/design/distribution/windows-support.html) |

## Acceptance

- The updater selects a signed DMG and validates its manifest digest.
- Both architecture builds pass the packaged-runtime smoke tests.
- Published size and SHA-256 match the release manifest.

**Why these tools**

| Reference | Use |
| --- | --- |
| [Apple Developer ID](https://developer.apple.com/help/account/certificates/create-developer-id-certificates) and [notarization](https://developer.apple.com/documentation/security/notarizing-macos-software-before-distribution) | Production acceptance criteria |
| Codex | Same shape: Developer ID signature and stapled ticket |
| Electron Builder | Package layout only |
| `codesign`, `notarytool` | Distribution signing. No second identity service |

## Implementation status

| Part | Status |
| --- | --- |
| Signer, CI credentials, signed-artifact selection | Implemented |
| Apple authentication, certificate issuance, notarization | External gates. Passing source tests is not evidence for them |
| Both-architecture notarization on a public release | Not established by the repository; the release workflow's run is the proof |
| Helper privacy-grant gate | Not performed: two version switches in a separate macOS user account |
| Installed local development App | Keeps its own identity; a production build is not part of local iteration |

[Automatic updates](https://fzkuji.github.io/OpenProgram/docs/reference/design/distribution/automatic-updates.html)
