# Lattice — what the word claims and what Miadi stores

**Date:** 2026-09-23
**Grounds:** the Miadi lattice surface — `types/lattice.ts`, `lib/lattice.ts`,
`components/lattice-graph.tsx`, `app/lattice/[key]/`, `app/lattices/[key]/`,
`app/api/lattice/[key]/`, `app/api/lattices/`
**Asked in:** jgwill/Miadi#679 point 17 — "app/lattice: good question, I never saw a lattice that made sense..."
**Verification:** mixed — the five sources resolved on Crossref on 2026-09-23; the
definitions below are standard results written from knowledge, not re-read from the books.
See [`source-ledger.yaml`](./source-ledger.yaml).

This is a quick look, not a full diamond. It exists so the decision on point 17
can stand on the fields the word "lattice" comes from.

---

## Intent-understanding

**Current reality.** Until 2026-09-23 no stored lattice could be seen: Next 16 passes
`params` as a Promise and the pages read `params.key`, so every key arrived as
`undefined` (fixed in `e226e56c`). The first lattice ever rendered is
[`example-679.lattice.json`](./example-679.lattice.json), built by hand from the 18
items of jgwill/Miadi#679 and stored at key `miadi-679-endpoint-deprecation`.

**Desired outcome.** A Miadi structure named "lattice" either satisfies the
definition of a lattice, or carries the name of what it is.

**Decision this supports.** Point 17 of jgwill/Miadi#679, in the talking circle that
issue prepares: keep, rename, or rebuild the lattice surface.

**Audience.** Guillaume and the circle deciding #679, and any agent asked to extend
`types/lattice.ts`.

---

## Context-layer

### Fields

| field | what it gives the question | anchor |
|---|---|---|
| Order theory / lattice theory | the definition the word claims | Birkhoff 1940, Davey & Priestley 2002 |
| Formal Concept Analysis | a lattice computed from a table of objects × attributes | Wille 1982, Ganter & Wille 1999 |
| Interactive narrative | the structure Miadi actually stores: a branching story graph | Riedl & Young 2006 |

### Terms

- **Partial order.** A relation ≤ that is reflexive, antisymmetric and transitive.
  The reachability relation of any DAG is a partial order.
- **Lattice.** A partial order in which every pair a, b has a **join** a ∨ b (one
  least upper bound) and a **meet** a ∧ b (one greatest lower bound). A finite
  lattice therefore has one top and one bottom element.
- **Formal context** (G, M, I). Objects G, attributes M, and the incidence I saying
  which object has which attribute.
- **Formal concept.** A pair (extent, intent): a set of objects and the set of
  attributes they all share, each determining the other exactly.
- **Concept lattice.** All formal concepts of a context, ordered by extent
  inclusion. The basic theorem of FCA: it is always a complete lattice.
- **Branching story graph.** Nodes are story units, edges are causal or temporal
  succession, branches are points where the audience's path can diverge.

### What Miadi stores

`StoryLattice` (`types/lattice.ts`) is a list of typed nodes (`scene`, `event`,
`beat`, `insight`, `bottleneck`, `branch`, `moment`, each with an optional
Medicine Wheel `direction`) and typed edges (`causality`, `temporal`, `leads_to`,
`echoes`). `lib/lattice.ts` computes entry points, exits, bottlenecks
(in-degree > 1 and out-degree ≥ 1), branches (out-degree > 1) and the longest path.
The API stores any JSON value. `isStoryLattice` checks only that `id`, `title`,
`nodes` and `edges` exist and that nodes carry `id` and `label`.

---

## Findings

- **F1 — It is not a lattice.** `StoryLattice` is a typed DAG, which is a
  branching story graph in the sense of Riedl & Young 2006. Nothing requires joins
  or meets. `example-679` has four exits (Retire, Archive, Replace, Keep) and no
  top element, so it fails the definition.
- **F2 — `echoes` is counted as order.** An echo says two nodes resonate, not
  that one precedes the other, and the relation has no direction of its own. The
  analysis still counts it in degrees and paths. In `example-679`,
  "15 ava/consultations" is reported as a bottleneck only because of the echo
  edge from "16 app/consultation-peek". Without it the node has in-degree 1.
- **F3 — Structural roles are both declared and computed.** `bottleneck` and
  `branch` are node types an author sets, and the analysis also derives them from
  topology. In `example-679` they already disagree: the six stream nodes are typed
  `beat` and computed as branches. `i15` is typed `scene` and computed as a
  bottleneck.
- **F4 — The "many dimensions" intuition fits Formal Concept Analysis.** Each
  attribute of a formal context is one dimension. The concept lattice shows every
  combination of attributes that actually occurs, with the objects that carry it,
  ordered by generality. That is a real lattice, and it is computed, not drawn.
- **F5 — Acyclicity is not enforced.** The type is described as a DAG, but neither
  the POST route nor `isStoryLattice` rejects a cycle. `analyzeLattice` carries a
  cycle guard so a cyclic value still renders.

## Options

- **O1 — Name it for what it is, repair the analysis.** Call the structure a story
  graph. Leave `echoes` out of degree and path analysis. Derive bottleneck and
  branch from topology instead of declaring them as types. Reject cycles on write.
  Small, and keeps the current viewer.
- **O2 — Build a concept lattice.** Accept a formal context (for #679: the 18
  surfaces × stream, lean, named replacement, depends-on-tide, …), compute the
  formal concepts, and draw the concept lattice. This is the structure that would
  show the circle something the issue text does not already say: which surfaces
  share which properties, and which property sets imply others.

**Recommendation.** O2 for the #679 circle. O1 if the page stays a story viewer.
The two can coexist under different names.

---

## Crosswalk

- Related packets: [`narrative-studies-and-digital-storytelling/`](../narrative-studies-and-digital-storytelling/)
  (story structure), [`content-visualization-and-exposure/`](../content-visualization-and-exposure/)
  (the key viewer pages `/keys`, `/redstones`, `/lattices` belong to that surface).
- Commits that made the first lattice visible: `e226e56c` (pages await params),
  `dd294da3` (DAG selects nodes, Structure panel, walkable neighbours),
  `329198df` (collect falls back to legacy `lattice:` keys).
- QMD: index this packet with the other `foundations/` packets. No cross-repo
  registry entry needed until a lattice surface exists outside Miadi.
