Skip to content

Latest commit

 

History

History
171 lines (144 loc) · 8.75 KB

architecture.md

File metadata and controls

171 lines (144 loc) · 8.75 KB

Architecture

Build flow

The sole upstream artifact is OpenAI's signed Linux .deb. Unattended builds resolve it through signed stable APT metadata rather than trusting the moving latest download alias.

  1. scripts/lib/upstream-linux-package.js selects amd64 or arm64, verifies OpenAI's signed stable metadata with the pinned repository key, and verifies the selected package digest and control fields.
  2. upstream-linux-package.sh extracts the package data archive without running maintainer scripts and validates /usr/lib/chatgpt.
  3. install.sh stages that directory as codex-app/, adds the compact launcher and metadata schema v2, then applies required core patches and explicitly enabled features.
  4. If no core or feature ASAR descriptor is active, resources/app.asar is never unpacked and its SHA-256 must equal upstream. Otherwise a temporary copy is patched and reported; deterministic repacking happens only if a descriptor reports changes. An unchanged report retains the official archive.
  5. Package builders transform the same staged tree into deb, RPM, pacman, a local Gentoo ebuild/payload, or AppImage output. Nix extracts the architecture-specific official package directly and wraps its ELF runtime.
flowchart LR
  A["Signed InRelease"] --> B["Verified Packages index"]
  B --> C["Verified chatgpt package"]
  C --> D["Official /usr/lib/chatgpt payload"]
  D --> E{"Core or feature ASAR descriptors active?"}
  E -- "none" --> F["Byte-identical app.asar"]
  E -- "active" --> G["Temporary deterministic patch"]
  F --> H["codex-desktop outputs"]
  G --> H
Loading

Trust boundaries

The repository key fingerprint is 3BFA0E4AE8B8CC16A2D9BA684A3B4A566C4660E4. latest download links are convenience aliases only. Trust is derived from InRelease, then the digest of the architecture-specific Packages file, then the package SHA-256 recorded in that index. Wrong signatures, hashes, package names, versions, architectures, or incomplete payloads fail closed.

Local input reuses package bytes while retaining signed verification by default. All builds verify without prompting or reading user input. Only --skip-oai-official-sig-verification selects the local exception. The exception retains structural checks and records signatureVerification: "skipped" in build provenance; it does not follow automatically from a signature or digest failure. Nix's offline builds use that explicit exception with their independently hash-verified pins.

The upstream source/key setup and maintainer scripts are never copied into the custom package. This prevents an official package-manager transaction from owning or replacing /opt/codex-desktop.

Ownership

Upstream owns Electron, Owl, native modules, bundled commands, application windows, single-instance behavior, URI handling, tray, login, and lifecycle. This repository owns source verification, optional features, packaging, AppArmor path adaptation, and transactional custom updates.

The launcher only establishes codex-desktop desktop identity, loads feature environment/prelaunch/argument/lifecycle hooks, forwards arguments, and waits when an after-exit hook exists.

The official Browser and Chrome plugins, their Linux extension host, and the plugin app-server protocol are upstream runtime components. The former generic Browser/Chrome Linux port layer is not part of the architecture. A separate thorium-chrome-plugin feature remains opt-in because Thorium is not present in the official browser registry.

Repository layers

Layer Primary owners
Source trust and extraction scripts/lib/upstream-linux-package.*
Candidate transaction and metadata install.sh, scripts/lib/install-helpers.sh, build-info.*
Thin runtime wrapper launcher/start.sh.template
Optional feature framework scripts/lib/linux-features.*, linux-features/
ASAR descriptors and reports scripts/patches/, scripts/patch-linux-window-ui.js, scripts/lib/patch-report.js
Cross-format payload assembly scripts/lib/package-common.sh, packaging/
Native update state machine updater/src/; rebuild payload: scripts/lib/package-common.sh
Reproducible Nix packaging flake.nix, nix/
Upstream drift automation scripts/automation/upstream-linux-package-watchdog/, .github/workflows/upstream-build-app.yml

Patches and features

scripts/patches/runner.js composes required core compatibility patches with descriptors from enabled features. The current core registry is empty: the verified upstream runtime natively consumes quit approval in its unique before-quit owner and owns shell-environment startup after app readiness. See the core patch registry for reproduction evidence and retirement criteria. Patch reports remain the candidate-acceptance contract. Enabled feature descriptors default to enforced acceptance even when their execution policy is optional: warnings or drift reject promotion unless an optional descriptor explicitly opts out with enforceWhenEnabled: false. Target/gate skips are not applicable; disabled feature modules are not loaded.

The committed feature config is empty. Features stage declarative resources, runtime hooks, package hooks, or narrowly scoped ASAR descriptors. Native helper crates are built when producing this distribution, not during every upstream runtime refresh.

Feature staging has separate application and native-package phases. App resources stay inside the app tree; package resources install udev, systemd, policy, or helper files only through validated package targets. The enabled manifest snapshot is recorded in build metadata so packaging and updater rebuilds cannot silently use a different selection.

Identity and data

Native packages use codex-desktop and /opt/codex-desktop; the official app uses chatgpt. The custom desktop entry is ChatGPT Community, with a community-marked icon; desktop entries and AppArmor paths are distinct. By default the upstream Codex profile is intentionally preserved for compatibility, so both runtimes must not run simultaneously. The optional community-profile-isolation feature instead pins Community to a separate Codex state directory and Electron profile and keeps app-server/child CLI resolution on the bundled Community codex. It does not change package identity or the official URL handler.

The wrapper has one narrowly scoped migration for bundled Browser and Chrome cache snapshots created by the former Linux port. It replaces a cache only when the bundled manifest matches and a retired marker is present, then restores the official socket/host contract. It never clears arbitrary plugin caches or user-authored plugins.

Updates

The Rust updater polls signed metadata, downloads into a version/architecture/SHA cache, and builds a native package in the configured workspace with the minimal packaged update-builder. After the managed app exits, it authorizes the package manager through pkexec, using a durable transaction and command-owner identity to reconcile interrupted installs. Package-manager failure can leave partial changes; this is distinct from the atomic sibling directory exchange used for manual generated-tree rebuilds. The previous managed package is retained for rollback. See Updater for both workflows. Legacy schema-v1 candidate state is reset without deleting installed or rollback packages. A schema-2 interrupted package transaction whose owner identity cannot survive a reboot is instead retained as failed evidence behind a manual-recovery barrier; it is never auto-reconciled as a live install.

Generated state

codex-app/, side-by-side candidates, transactional backups, dist/, dist-next/, Cargo target/, patch reports, and local feature configuration are generated state. They are never source owners and should not be edited or committed. See Generated and runtime notes.

Architecture invariants

  • The latest signed stable upstream package is the only supported baseline.
  • Without a required core patch or enabled ASAR feature, the clean ASAR hash equals the hash of resources/app.asar inside the verified official package. Required core and enabled feature changes are explained by the patch report; an active descriptor does not imply that every build changes bytes.
  • Upstream package scripts and APT source configuration never enter the custom output.
  • codex-desktop package identity and ChatGPT Community display identity remain distinct from official chatgpt / ChatGPT.
  • Optional behavior stays disabled in committed configuration.
  • A core patch needs evidence of a mandatory baseline failure and a required regression test.
  • Package/update/launcher/framework changes are cross-format unless proven otherwise.