# LUMEN: decentralized image generation and editing

**LUMEN** is Phase's decentralized image generation and reference-image editing workload. Built directly on the Apache-2.0 Phase substrate alongside [LUCID](install.md), LUMEN brings verified local and Trusted Circle diffusion into LUCID Desktop using the same Ed25519 node identities, signed job manifests, streaming progress commitments, and default-deny peer authorization.

> [!NOTE]
> **Merged on `main` (`7e3547a`) — active qualification / preview:** First-party LUMEN image compute (`crates/lumend`, `lucidd` `image_engine` + trusted-circle cluster offload with default `share_images = false`, and LUCID Desktop `LumenControls`) is merged into `main` and passed physical two-Mac qualification (`Qwen-Image 2.1 Turbo` at `1024x1024`, `31+1` blocks, `255.445 s`, plus opt-in refusal, mid-job revocation without publishing, and re-enable recovery). It is **not yet shipped in default `v0.2.0-rc42` public installers** while signed runtime distribution, cross-platform/Tor qualification, and distributed FLUX editing remain open.

## Architecture on the Phase substrate

LUMEN reuses every cryptographic and networking primitive of the Phase core without introducing a separate account system, central broker, or trust model:

- **Typed workload (`JobSpec::ImageGen`):** Clients submit image generation and editing jobs inside an Ed25519-signed `SignedManifest<JobSpec>` specifying the prompt, optional negative prompt, seed, resolution, step count, guidance scale, target model profile, and optional reference-image content identifier (CID).
- **Verified artifact plane:** Both the `stable-diffusion.cpp` (`sd-cli`) runtime binary and every model component—diffusion checkpoints, text encoders, VAEs, and input reference PNGs—are addressed and verified by **SHA-256 CID** before execution. No unverified binary or weight file is launched.
- **Streaming progress and signed receipts:** As denoising steps progress, workers emit bounded `JobEvent::Progress` updates and preview frames, fold output bytes into `CommitmentAccumulator`, and close the job with a terminal Ed25519 `SignedReceipt`. Clients verify the receipt signature and output commitment before presenting or exporting the final image.
- **Distributed GPU diffusion (`/phase/shard-rpc/leased/1.0.0`):** When pooling GPUs across enrolled Trusted Circle machines, coordinators inspect signed capacity offers (`/phase/capacity-offer/1.0.0`) and lease remote helper memory over Noise-encrypted `/phase/shard-rpc/leased/1.0.0` streams.

## Reviewed model profiles

LUMEN qualification targets three curated profiles spanning lightweight baseline generation, reference-image editing, and fast distilled synthesis:

| Profile | Capabilities | Target Use Case | Verification Scope |
|---|---|---|---|
| **SD 1.5** | Text-to-image | Fast baseline generation and low-VRAM verification on entry-level GPUs. | Pinned `sd-cli` runtime + checkpoint SHA-256 CID. |
| **FLUX.3 Klein** | Text-to-image + **PNG reference-image editing** | High-fidelity generation and content-addressed image editing using an attached PNG reference CID. | Pinned `sd-cli` runtime + diffusion weights, text encoder, VAE, and reference PNG SHA-256 CIDs. |
| **Qwen-Image 2.1 Turbo** | Text-to-image (distilled) | Low-step generation with strong prompt adherence and typography rendering. | Pinned `sd-cli` runtime + diffusion weights, text encoder, and VAE SHA-256 CIDs. |

All multi-component bundles (diffusion weights, text encoders, and VAEs) are resolved from local verified storage or fetched with exact SHA-256 verification before `sd-cli` is spawned.

## Shared GPU arbitration and Trusted Circle pooling

Running text models and diffusion models on the same GPU without coordination leads to VRAM exhaustion, driver resets, or stalled inference streams. LUMEN solves this directly in the daemon scheduler:

- **Exclusive GPU arbitration (`SlotQueue::try_acquire_exclusive`):** Before launching a diffusion pass, LUMEN acquires exclusive ownership of the local GPU through `SlotQueue::try_acquire_exclusive`. Active LUCID text inference (`llama.cpp` or MLX) and LUMEN diffusion jobs never double-book VRAM on the same machine, and queued text prompts wait cleanly in FIFO order rather than failing mid-stream.
- **Distributed GPU diffusion across Trusted Circle helpers:** Helpers that opt into a Trusted Circle advertise available VRAM via signed `/phase/capacity-offer/1.0.0` records. For larger profiles or multi-GPU setups, the coordinator leases helper capacity over `/phase/shard-rpc/leased/1.0.0`—enforcing the same default-deny enrollment allowlist and encrypted Noise transport used by [Tier-1 Trusted-Circle sharding](trusted-circle-sharding.md).

## Chat-first UX in LUCID Desktop

LUMEN integrates directly into LUCID Desktop's chat workspace rather than forcing users into a separate node-graph tool:

- **`/image` command in Chat:** Type `/image <prompt>` inside any Desktop Chat thread (or attach a PNG reference image when using **FLUX.3 Klein**) to dispatch a `JobSpec::ImageGen` job on your local GPU or enrolled Trusted Circle.
- **Inline previews and explicit PNG export:** Verified image outputs render inline inside the chat stream. Images are not silently written across your filesystem; saving a generated or edited image requires an explicit **Export PNG** action.
- **Tor / TailsOS safety gate:** LUMEN image generation and remote diffusion helpers are **gated off when Tor / TailsOS mode is active** until end-to-end Tor-safe transport, metadata isolation, and artifact qualification are complete.

## Current qualification status

LUMEN is integrated on `main` (`7e3547a`, `crates/lumend` retained as a standalone CLI/worker alongside `lucidd` first-party orchestration) with **physical two-Mac qualification passing** (`Qwen-Image 2.1 Turbo` `1024x1024`, `31+1` blocks, `255.445 s`, plus default-deny refusal, mid-job revocation without publishing, and re-enable recovery), and is **not yet bundled in default `v0.2.0-rc42` public desktop installers**.

Remaining qualification gates before promoting LUMEN into default public LUCID installers:

1. Signed runtime distribution and real sidecar packaging across Apple Silicon Metal, Windows (CUDA/Vulkan), and Linux (CUDA/Vulkan).
2. Cross-platform verification of `SD 1.5`, distributed `FLUX.3 Klein` PNG reference-image editing, and model fragment residency.
3. Private helper transport hardening, resource/file lifecycle & crash recovery, and stress testing `SlotQueue::try_acquire_exclusive` handoffs between continuous LUCID text chat and concurrent `/image` jobs.
4. Explicit Tor-mode gating checks confirming zero unintended binary downloads or non-Tor connections when Tor / TailsOS mode is enabled.

For the underlying Phase protocol, receipt cryptography, and workspace crate layout, see [Phase network protocols](protocols.md), [Cryptography, receipts and verification](cryptography-and-receipts.md), and [Workspace architecture, crates and Plasm](architecture-and-crates.md).
