No description
  • Rust 92.5%
  • Python 7.3%
  • HTML 0.1%
Find a file
2026-03-11 19:24:54 +00:00
.github/workflows Land relayout windows and truth-hardening pass 2026-03-07 17:53:33 +00:00
assets Keep adapters in core and move render ownership to labs 2026-03-11 09:10:05 +00:00
book Keep adapters in core and move render ownership to labs 2026-03-11 09:10:05 +00:00
crates Gate HarfBuzz shaping and add cost model docs 2026-03-11 19:23:03 +00:00
diagnostics Keep adapters in core and move render ownership to labs 2026-03-11 09:10:05 +00:00
docs Gate HarfBuzz shaping and add cost model docs 2026-03-11 19:23:03 +00:00
labs Keep adapters in core and move render ownership to labs 2026-03-11 09:10:05 +00:00
tools/dev Move font and oracle assets into labs 2026-03-11 01:58:30 +00:00
.gitignore Land relayout windows and truth-hardening pass 2026-03-07 17:53:33 +00:00
Cargo.toml Keep adapters in core and move render ownership to labs 2026-03-11 09:10:05 +00:00
CHANGELOG.md Keep adapters in core and move render ownership to labs 2026-03-11 09:10:05 +00:00
CODE_OF_CONDUCT.md Implement glyphrazor-core and establish workspace structure 2026-02-16 13:32:10 +00:00
CONTRIBUTING.md Collapse core into a single glyphrazor crate 2026-03-11 07:16:48 +00:00
deny.toml Split integration.rs into integration/ module directory 2026-03-06 16:32:26 +00:00
LICENSE Initial commit 2026-02-16 13:24:19 +00:00
QUICKSTART.md Keep adapters in core and move render ownership to labs 2026-03-11 09:10:05 +00:00
README.md Keep adapters in core and move render ownership to labs 2026-03-11 09:10:05 +00:00

GlyphRazor

GlyphRazor Logo

GlyphRazor is a deterministic, pluggable large-context text execution pipeline for persistent text surfaces, especially large DOM-based LLM chat workloads. Update cost scales with local change, not accumulated history.


The problem

You are in a Claude or ChatGPT session. The conversation is 40,000 tokens long. A new message streams in. Why does any work proportional to those 40,000 tokens happen? It should not.

Only the new tokens should cost anything. The rest is retained history: it does not move, it does not change, and it has already been laid out.

GlyphRazor exists to make that cost model real.


What GlyphRazor is

GlyphRazor sits between shaping and rendering. It retains LayoutArtifacts, computes deterministic ExecutionPlans, and ensures unchanged history stays reusable.

Diagram A — pipeline boundary

App / DOM / text model
        ↓
Segmentation / bidi
        ↓
HarfBuzz or equivalent
        ↓
GlyphRuns / shaped input
        ↓
GlyphRazor LayoutArtifact
        ↓
ExecutionPlan
        ↓
Renderer backend

GlyphRazor begins after shaping. GlyphRazor ends before renderer realization.

Diagram B — internal layering

glyphrazor
  ├─ foundation
  ├─ layout
  ├─ render
  ├─ adapters
  ├─ ffi        (feature-gated)
  └─ wasm       (feature-gated)
      ↓
optional reference backends under labs

No upward arrows. No backend logic in retained artifacts.


What GlyphRazor is not

  • GlyphRazor is not a shaping engine.
  • GlyphRazor is not a UI framework.
  • GlyphRazor is not a scene graph.
  • GlyphRazor is not primarily a generic GPU text renderer.

HarfBuzz, rustybuzz, Skrifa, and platform shapers handle shaping. Proven renderers handle draw realization. GlyphRazor handles retained large-context execution between them.


Primary workload

The canonical GlyphRazor workload is a long-lived LLM conversation surface:

  • Message history grows continuously.
  • New output streams in token by token.
  • Scroll is constant.
  • Cursor, selection, highlights, and citations change independently.
  • Retained history must not be re-traversed on each update.

Run the primary proof:

cargo run --example llm_dom_surface -p glyphrazor --release

Expected result:

  • each append recomputes exactly 1 artifact
  • scroll recomputes 0 artifacts
  • overlay updates recompute 0 artifacts

That is the large-context guarantee.


Pluggable by design

GlyphRazor exposes the shaping seam above the retained core and the renderer seam below it.

ShapingBackend     ← external shaping systems
       ↓
GlyphRazor         ← retained large-context execution
       ↓
RendererBackend    ← your renderer backend

Both seams are available from the public facade:

use glyphrazor::{RendererBackend, ShapingBackend};

labs/crates/glyphrazor-wgpu is the optional reference wgpu backend crate and the working end-to-end draw path. It is not the product. The product is the retained execution architecture inside the single glyphrazor crate.

See docs/architecture/renderer_adapter.md for the backend contract.


Architectural guarantees

Guarantee Invariant
Backends consume plans only: no shaping, no layout mutation INV-1
LayoutArtifact remains backend-neutral and CPU-resident INV-2
Equivalent inputs and mutation sequences produce equivalent plans INV-3
Pre-shaped input is preserved exactly INV-4
Scroll and viewport transforms do not relayout unchanged content INV-5
Overlay changes do not invalidate base text artifacts INV-6
Glyph representation policy is separate from retained execution INV-7
Large-context workloads outrank generic rendering polish INV-8

Canonical source: docs/architecture/invariants.md


Canonical proof suite

Each canonical example has the same structure:

  • one-sentence purpose
  • architecture diagram
  • exact input/output boundary
  • live metrics
  • what this proves

The real HarfBuzz preservation proof lives in:

Example Proves
harfbuzz_large_context GlyphRazor begins after shaping and retains large pre-shaped surfaces
terminal_surface Append-heavy streams scale with new lines, not scrollback history
editor_surface Local edits stay bounded and overlays stay isolated
llm_dom_surface Large DOM / LLM chat workloads remain O(change), not O(history)

Supporting examples:


Crate responsibilities

Crate Contract
glyphrazor Canonical core crate: retained execution, layout geometry, renderer seams, shaping adapters, and optional ffi / wasm surfaces
labs/crates/glyphrazor-render Labs-side render-style, shader, and effect ownership for reference backends
labs/crates/glyphrazor-font Labs-side reference font crate for parsing, metrics, outlines, color, SVG, and variation work
labs/crates/glyphrazor-wgpu Optional reference wgpu backend crate
labs/crates/glyphrazor-msdf Optional distance-field glyph representation policy
labs/crates/glyphrazor-atlas Optional atlas packing and residency utilities for backend crates

The core crate does not depend on the labs crates above. Labs backends and font experiments depend on glyphrazor, not the other way around.


Docs


labs/ contains archived demos, phase-era examples, research notes, reference backends, and the non-canonical archive cut from core. It is not required to understand the retained large-context architecture.