# AIFT Living Spectrum — design system v1 (proposed)

Status: **draft implementation** — tested in headless Chromium and Node; not yet adopted by any production surface, not verified on a physical Android device.

Reference page: [`/living-spectrum`](../../living-spectrum.html) · Source: [`assets/living-spectrum/`](../../assets/living-spectrum/)

The Living Spectrum is the shared visual language for Federation websites, the Universal Desktop (`/os/`) and the Aetherion Android app. Its central figure is the **Tree of Emergence**, generated procedurally so that the toroidal circulation *is* the tree rather than a ring drawn behind it.

The toroidal cosmology, chakra correspondences and colour meanings are an artistic and philosophical framework. They are not scientific claims about consciousness or space-time, and no colour or stage ever grants permission, signals health, or changes runtime admission.

## Package

| File | Contract | Purpose |
| --- | --- | --- |
| `tokens.json` | `aift.living-spectrum.tokens.v1` | Phases, circulation stops, surface colours, typography, Fibonacci spacing, motion, quality tiers |
| `spectrum.mjs` | mirrors `tokens.json` (test-enforced) | OKLab circulation colour `spectrumAt(u)`, contrast helpers, `awakeningRank(u)` |
| `tree-engine.mjs` | `aift.living-spectrum.geometry.v1` | Pure, deterministic geometry: field lines, trunk, branches, roots, leaves, fruits, seeds |
| `tree-renderer.mjs` | — | Dependency-free Canvas 2D renderer with adaptive quality |
| `awakening-controller.mjs` | `aift.living-spectrum.awakening.v1` | Event-driven Awakening state machine |
| `parity-v1.json` | — | Cross-platform parity vectors (regenerate with `node scripts/generate-living-spectrum-parity.mjs`) |

Everything is plain ES modules with no third-party dependencies and no network access, so any surface can import it directly: `import { generateTree } from '/assets/living-spectrum/tree-engine.mjs'`. Please don't copy it into other repositories; import it, or port it against `parity-v1.json`.

## Geometry: how the torus becomes the tree

Every structure comes from one axisymmetric Stokes stream function in the meridional (r, y) plane:

    ψ(r, y) = r² · (1 − r²/A(y)² − y²/B(y)²)

`A` and `B` blend smoothly (logistic in y) between a tall, wide canopy lobe and a shallower root lobe. The region where ψ > 0 is a horn torus whose inner edge is the vertical axis. The poloidal velocity `(−∂ψ/∂y, ∂ψ/∂r)/r` runs up the axis, out over the crown, down the outside and back in at the root tip. A small toroidal twist `τ/(r + 0.18)` makes field lines spiral, most tightly around the trunk.

- **Field lines**: level sets of ψ at golden-ratio-spaced levels, traced with RK4, resampled by arc length and closed exactly. Field line *k* starts at azimuth `k · 137.508°`. The lines nearest the separatrix bundle into the trunk and the returning envelope.
- **Trunk**: helical fibres around the axis that flare into the root crown at the Greenshift equilibrium.
- **Branches**: grown from Fibonacci-spaced trunk heights. Each step blends the current heading with the local flow, so branches rise, arc outward and fold back down as returning field lines. Children start at 1 − φ⁻ᵏ along the parent, their length is scaled by 1/φ, and their width is φ⁻ᵈᵉᵖᵗʰ.
- **Roots**: grown along the *reversed* flow, so they descend, spread and curl back up into the outer return.
- **Leaves**: Fibonacci phyllotaxis (golden-angle rotation) along the outer canopy branches.
- **Seeds**: Vogel spiral `r = c√n, θ = n · 137.508°` on the Greenshift equilibrium plane.
- **Fruits**: self-similar miniature tori at branch tips.

**Circulation phase** `u ∈ [0, 1)` is a piecewise-linear normalised angle about the circulation eye:

| u | where | colour |
| --- | --- | --- |
| 0 | trunk axis at the equilibrium | Greenshift |
| 0 → 0.25 | rising up the trunk | cyan → blue → indigo → violet |
| 0.25 → 0.5 | crown arcing over the canopy | violet → Whiteshift seam |
| 0.5 → 0.75 | outer root lobe descending | white → amber → vermilion → crimson → Blackshift |
| 0.75 → 1 | root axis rising | crimson → vermilion → amber → Greenshift |

So the trunk carries the familiar bottom-to-top chakra progression, while each loop shows both pathways from the directive. Expansion runs Green → Yellow → Orange → Red → Black, and convergence runs Green → Cyan → Blue → Indigo → Violet → White. Each returns to Greenshift. Colours are interpolated in OKLab, and tests bound the largest step between adjacent samples, so there are no stripes.

**Determinism.** The `mulberry32` PRNG is seeded with the FNV-1a hash of `seed|tier`. `geometryDigest()` is a regression guard for JavaScript. Native ports should match the sampled coordinates in `parity-v1.json` within 1e-6, because transcendental functions are not bit-identical across runtimes.

## Phases and tokens

Phase ids and **pigment** colours match `SpectralPhase.java` from AIFT-Runtime PR #31/#37, so web and native surfaces share one vocabulary. **Luminous** colours are a separate set used for emitted light on obsidian, starting from the master directive palette. Cyan is transitional and is not a Movement. Purpleshift always sits between Blueshift and Whiteshift. The movement names used in PR #31 are not repeated here as doctrine. They still need to be reconciled with canonical sources before any Federation-wide use.

## Awakening contract

The controller exposes `apply({ check, status, detail?, progress? })`, `retry(check)`, `cancel()`, `snapshot()` and `subscribe(fn)`.

| Stage | Phase | Check | Gate |
| --- | --- | --- | --- |
| Dormancy | Blackshift | `state.discovered` | |
| Foundation | Redshift | `device.compatible` | |
| Formation | Sacral | `storage.ready` | |
| Illumination | Solar | `artifacts.verified` | `passed` requires a 64-hex `sha256` |
| Emergence | Greenshift | `runtime.started` | |
| Communication | Blueshift | `inference.verified` | `passed` requires `generatedTokens > 0` and a `model` identity — an HTTP 200 alone is rejected |
| Understanding | Indigo | `session.restored` | `not-applicable` is allowed only on first awakening |
| Integration | Purpleshift | `apps.initialized` | |
| Awakening | Whiteshift | — | reached only when every check above has passed |

Rules:

- Stages are a strict prefix. A later pass never lights a stage while an earlier check is outstanding.
- A failure blocks at the affected stage. `retry` resets that check and every later one.
- Progress must be a real `{received, total}`, and invalid progress is rejected.
- Nothing advances on time.
- Lifecycle modes are `first-awakening`, `returning`, `resume`, `recovery` and `update`.

The renderer's `setIllumination(snapshot.illumination)` lights the tree along `awakeningRank`, from roots up through Greenshift to the crown. The outer return path closes last.

`ANDROID_RUNTIME_STATE_HINTS` is a *proposed* mapping from the Android `RuntimeState` to check events. `READY` maps only to `runtime.started`, never to verified inference.

## Rendering and performance

- Additive light on obsidian. Strokes are batched by colour and alpha into `Path2D` groups, and bloom is a cheap quarter-resolution copy.
- **Modes**:
  - *Cinematic*: animated, with slow rotation and particles circulating along the actual field lines.
  - *Calm*: a static render with no animation loop and the calm geometry tier.
  - `prefers-reduced-motion` selects Calm.
- **Adaptive quality** responds to the measured frame interval, which includes rasterisation, not to draw-call time. It steps down from cinematic to standard, then to 1× resolution, then drops bloom. It steps back up only on devices with at least 8 cores and 8 GB that sustain a fast frame interval.
- The animation loop stops when the document is hidden.
- `setActivity('active')` speeds up circulation. Call it only while a real generation stream is being observed. The animation is not a claim of consciousness or emotion.
- Input: drag to rotate, pinch or wheel to zoom, and arrows / `+` / `-` / `0` on the focused canvas.

Headless Chromium measurements in a container with no GPU (software rasterisation), standard tier:

| Viewport | Measured | Notes |
| --- | --- | --- |
| 390×844 @2× | ≈ 37 fps | |
| 1280×800 @2× | ≈ 19 fps | before adaptation |
| 1280×800 @2× | ≈ 35 fps | after adaptation drops to 1× resolution |

Physical-device numbers are still needed.

## Verification

```sh
node --test tests/living-spectrum.test.mjs
node scripts/generate-living-spectrum-parity.mjs --check
python3 -m http.server 4178 --bind 127.0.0.1 &
node tests/living-spectrum-browser.mjs   # needs playwright + Chromium; screenshots in artifacts/living-spectrum/
```

The browser test runs at 360, 390, 768 and 1280 CSS px. It checks:

- no console errors and no remote requests;
- Awakening completes only through recorded events, and the lit canvas area grows;
- failure → blocked → retry;
- keyboard input;
- no horizontal overflow;
- reduced motion → Calm with no animation loop;
- a hidden tab stops the loop.

## Physical-device acceptance checklist (not yet performed)

1. Open `/living-spectrum` on the operator's ARM64 Android phone (Chrome and WebView). Record the device, OS, screen size and source SHA.
2. Check portrait and landscape, and confirm the panel never covers the root lobe.
3. Drag, pinch, rotate the device, background and resume, and check frame-rate stability. Report the `Quality:` readout after 10 s.
4. Turn on TalkBack and read through the canvas description, the stage list and the controls in order. Test large fonts and system reduced-motion.
5. Watch battery and thermal behaviour over 5 minutes in Cinematic mode against Calm.
6. Native port: implement `SpectralTreeView` against `parity-v1.json` (samples within 1e-6). Feed its illumination from `AwakeningController` events produced by `AetherionService` checks, never from a timer.

## Next integration steps

- `/os/` desktop wallpaper and Aetherion window (PR #69/#72/#75 owners): import `tree-renderer.mjs` and map gateway state to Awakening checks.
- AIFT-Runtime Android (PR #25/#31 owners): a Java port of `tree-engine` using the parity vectors, plus a native Awakening screen driven by the service's real states.
- Other Federation sites: import tokens and the renderer from this origin instead of copying them.
