Metadata-Version: 2.5
Name: overset
Version: 0.2.0
Summary: A deck linter: measures what a slide actually renders -- text off the slide, out of its box, colliding, too small, too faint, off-brand -- with ruff-style rule codes
Project-URL: Repository, https://github.com/scale-venture-partners/overset
Author: Scale Venture Partners
License-Expression: MIT
License-File: LICENSE
Keywords: accessibility,brand,layout,linter,powerpoint,pptx,slides
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Office/Business :: Office Suites
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.11
Requires-Dist: pillow>=13.0.0
Requires-Dist: python-pptx>=1.0
Provides-Extra: vision
Requires-Dist: httpx>=0.27; extra == 'vision'
Description-Content-Type: text/markdown

# overset

> **Status: alpha (0.2.0).** Rule codes and config keys may still change. Render rules depend on
> LibreOffice and poppler, and thresholds are tuned on a limited set of decks. The vision rules are
> experimental, and "as PowerPoint shows it" is an emulation of PowerPoint's layout in LibreOffice, not
> PowerPoint itself.

A deck linter. It renders a `.pptx` and **measures** what each slide actually
shows: text off the slide, text spilling out of its frame, frames colliding,
type too small, text too faint, fonts and colours off the brand. It also checks
what an audience or a screen reader can't see at a glance -- missing titles and
alt text, reading order, overloaded lists -- and reports everything with
ruff-style rule codes you can select, ignore, and configure.

```console
$ overset product_overview.pptx --config examples/brand.toml
product_overview.pptx:slide 2: OVS002 text spills out of 'text105'
    Up 42% year over
product_overview.pptx:slide 3: OVS203 167 words, over 90
product_overview.pptx:slide 4: OVS203 99 words, over 90

3 findings in 1 deck (OVS203 ×2, OVS002 ×1).
```

*Overset* is the typesetter's word for text that doesn't fit its frame.

It is the companion to [riff](https://github.com/scale-venture-partners/riff), which lints a deck's
*words*. overset lints what the words *look like* on the slide.

## Why measure

A model reviewing its own slides misses things. A generated deck that the model had inspected slide by
slide still shipped with a title running off the top of the slide and a caption slid out of its
highlight pill. Both are measurable: LibreOffice renders the deck, and
poppler's `pdftotext -bbox-layout` reports every word's box, including words
pushed past the slide edge, which come back with negative coordinates. overset
compares those boxes with the frames in the file.

## Install

```console
uv tool install overset
uv tool install "overset[vision]"   # + vision rules (OVS4xx)
```

The render rules need **LibreOffice** and **poppler** on PATH
(`brew install --cask libreoffice && brew install poppler`, or
`apt install libreoffice-impress poppler-utils`). Without them,
`--no-render` runs the file-only rules, and a failed render is reported:
the render rules are listed as *skipped*, never as passed.

## Usage

```console
overset deck.pptx                         # every default rule
overset deck.pptx --no-render             # file-only rules, no LibreOffice
overset deck.pptx --vision                # add the vision-model review (OVS4xx)
overset *.pptx --select OVS0 --format json
overset deck.pptx --keep-render out/      # keep the PDF and slide PNGs
overset --list-rules
overset --explain OVS002
```

**Exit codes:** `0` clean, `1` findings, `2` usage or file error.

## Rules

| Code | Kind | Rule |
|---|---|---|
| OVS000 | structure | The file isn't a well-formed package: a part with no content type, a relationship to a missing part, XML that doesn't parse (what PowerPoint offers to "repair") |
| OVS001 | render | Rendered text runs past the slide edge |
| OVS002 | render | Rendered text spills out of its own frame |
| OVS003 | render | Text from two frames is drawn on top of each other |
| OVS004 | structure | A text frame extends past the slide edge |
| OVS005 | structure | Shapes that line up with nothing else on the slide *(off by default)* |
| OVS006 | structure | Content weighted heavily to one side of the slide *(off by default)* |
| OVS007 | structure | Too little empty space on the slide *(off by default)* |
| OVS008 | render | A slide far busier (edge density) than the rest of its deck *(off by default)* |
| OVS009 | render | Text set over a busy background *(off by default)* |
| OVS101 | structure | Text set below the minimum size (after shrink-to-fit) |
| OVS102 | structure | A font outside the configured set |
| OVS103 | structure | A colour outside the configured palette |
| OVS104 | render | Text too close in tone to what is behind it (sampled from pixels) |
| OVS105 | structure | More than `max-font-families` (2) typeface families in the deck *(off by default)* |
| OVS106 | structure | A whole paragraph set in bold, italic or capitals |
| OVS107 | structure | Underlined text that isn't a link |
| OVS108 | structure | More than `max-colors` (6) distinct text and fill colours on a slide *(off by default)* |
| OVS109 | structure | Text in a vivid saturated blue |
| OVS110 | structure | Saturated red and blue side by side (red text on blue, or touching red and blue shapes) |
| OVS111 | structure | Body text set as large as the title *(off by default)* |
| OVS112 | structure | A slide whose fonts or title size the rest of the deck doesn't use *(off by default)* |
| OVS201 | structure | A placeholder left empty |
| OVS202 | structure | A picture stretched out of its aspect ratio |
| OVS203 | structure | More words on a slide than an audience will read (a coarse backstop; OVS209–211 are the specific checks) |
| OVS204 | structure | A slide with no title (no title placeholder, or an empty one) |
| OVS205 | structure | Two slides share a title |
| OVS206 | structure | A picture, chart or graphic with no alt text, or only a file name for one |
| OVS207 | structure | A table with no header row |
| OVS208 | structure | A section left with PowerPoint's default name ("Default Section", "Untitled Section") |
| OVS209 | structure | A list with more than `max-bullets` (4) items at one level |
| OVS210 | render | A bullet that renders on more than `max-bullet-lines` (2) lines |
| OVS211 | structure | Bullets nested more than `max-bullet-depth` (2) levels deep |
| OVS212 | structure | A screen reader's reading order doesn't follow the layout, or the title isn't read first |
| OVS301 | structure | Two consecutive slides use the same layout *(off by default)* |
| OVS401–406 | vision | Clutter, weak hierarchy, misalignment, text over busy images, monotonous sequences, a slide that doesn't belong *(opt-in)* |

Three kinds, by what a rule needs:

- **structure** reads the `.pptx` alone: offline, milliseconds.
- **render** measures a LibreOffice render: offline, seconds, and
  deterministic.
Rules marked *off by default* turn on with `extend-select`: their thresholds come from a corpus of
real decks, not yet from labelled data. See [docs/corpus.md](docs/corpus.md).

- **vision** asks a multimodal decision model yes/no questions about each slide
  (and each pair of slides), and reports its probability as the finding's
  confidence. It's for the questions nothing can measure (is this slide
  cluttered, do two slides in a row look the same). Opt-in. Measured problems
  are explicitly kept out of the questions. See [Vision rules](#vision-rules).

### Rendered as PowerPoint shows it

The audience opens the deck in PowerPoint, so that is the layout overset measures. The two renderers
disagree about one thing that matters a lot: **shrink text on overflow** (`<a:normAutofit>`).
PowerPoint applies the scale *stored* in the file when it opens a deck, and recomputes it only when
someone edits the text. A bare `<a:normAutofit/>` therefore shows at 100%. LibreOffice recomputes the
shrink on every render, so text that overflows in PowerPoint fits in LibreOffice, and in any preview
LibreOffice made.

Before rendering, overset freezes every shrink-to-fit box at its stored `fontScale` and
`lnSpcReduction` (100% and 0 when absent). LibreOffice then draws PowerPoint's layout: the same line
breaks, and the same text running into the next box. `render-as = "libreoffice"` turns this off.

*Seen in practice:* a generated deck rendered cleanly in LibreOffice previews, yet its cover subtitle and
closing questions overlapped when opened in PowerPoint. The generator wrote a bare `normAutofit` and sized
its boxes by estimate, counting on a shrink that PowerPoint never applied.

### Measurement notes

- `pdftotext` boxes run from a font's ascender to its descender, not its ink.
  A correctly placed 80pt title sticks out of its frame's top by about a fifth
  of its height. Overflow allowances therefore scale with each word, and
  collisions compare approximate ink, not metric boxes.
- Frames set to **grow with their text** are exempt from OVS002: their stored
  box is stale, not wrong. OVS001 and OVS003 still catch growth that runs off
  the slide or into something else.
- Words no frame claims (text drawn by a chart or SmartArt) are left alone,
  not reported.
- overset renders the deck itself rather than trusting someone else's preview
  images, which can be stale.
- Contrast is sampled from the pixels under each block of words: the
  background is the commonest colour, and the ink is whichever candidate
  contrasts with it most -- every colour with a real share of the pixels, plus
  the farthest one in tone. That handles digits on a dot smaller than their box
  (paper around the dot is not the ink) and small thin type (whose ink is spread
  over many faint shades).
- Contrast thresholds follow WCAG 2.2 SC 1.4.3: 4.5:1 for body text and 3:1 for
  large text (18pt and up, or 14pt bold), taken from the run each word was set
  in. A word whose size isn't known is held to 4.5:1. A projector lowers
  contrast further, so treat these as floors.
- Words are attributed to frames by reading order *and* column: pdftotext reads
  a row of cards line by line across the columns, so a word continues a frame's
  sequence only if it sits in that frame's column.
- The package is checked before the deck is read (OVS000). A deck python-pptx
  can't load is reported as that finding, not as overset failing; a file that
  isn't a zip at all (a `~$deck.pptx` lock file) is a usage error.
- Decks that embed their fonts render in those
  fonts. For others, `font-dirs` registers font folders with fontconfig.
- Groups are flattened: each child shape is checked on its own, placed through
  the group's transform, and named with its group (`'Card 2 > TextBox 5'`).
- Font sizes inherited from the layout, master or presentation defaults are
  resolved, so OVS101, OVS104 and OVS111 see template text at its real size.
  Fonts and colours are taken as stated (theme fonts resolved for OVS105);
  colours the file doesn't state as RGB are not checked.
- OVS004 tests the part of a frame text can occupy -- the box less its inner
  margins -- so padding hanging over the edge is fine.
- OVS202 allows for a small image's pixel rounding: a 28x32 icon's aspect ratio
  is only known to about 4%.

## Vision rules

The OVS4xx rules use a *decision model*: one that returns a probability per yes/no question
instead of generated text, so it costs a fraction of a language model and answers fast
enough to look at every slide. overset sends it one request per slide (OVS401-404), one per
slide with the contact sheet for reference (OVS406), and one per consecutive pair (OVS405).

```console
export OPENAI_API_KEY=...
overset deck.pptx --vision                           # openai:gpt-6-luna, the default
overset deck.pptx --vision --select OVS405           # ask fewer questions
```

The model is a `provider:name` spec in `vision-model`. Today the one provider is `openai`, which
speaks OpenAI's [Decisions API](https://developers.openai.com/api/docs/guides/decisions)
(`POST /v1/decisions`, public beta, `gpt-6-luna` the only model). `OPENAI_BASE_URL` points it at
any server that speaks the same protocol. A provider is added by registering a class with a
`predicates(prompt, questions)` method in `overset/decisions.py`; only add one whose image wire
format you have checked. pydantic-ai's decision models (Jev, System One), as of 2.53, take text only, so
they can't look at a slide.

**Thresholds are not tuned to this model.** `vision-threshold` (0.7) is a probability, and a
model's stated probabilities need not match how often it is right: one published comparison
of `gpt-6-luna` found its high probabilities well over-confident. Run a deck you know the
answer to, check which findings are real, and set the threshold for your decks before
trusting the output. A question the model refuses is counted in the run's notes.

## Configuration

`overset.toml` (or `.overset.toml`, or `[tool.overset]` in `pyproject.toml`),
found from the deck's folder upward. Flags override it.

```toml
select = ["OVS0", "OVS1"]           # omit for every default-on rule
ignore = ["OVS203"]
extend-select = ["OVS301", "OVS005"]  # turn on off-by-default rules
extend-ignore = []
fonts = ["Inter"]                   # by family: "Inter Medium" is Inter
palette = ["20211B", "F7F5F2", "00C756"]
palette-tolerance = 12              # RGB distance
# palette-delta-e = 5               # or match perceptually (CIEDE2000) instead
max-colors = 6                      # distinct text and fill colours on a slide
font-dirs = ["fonts/"]              # relative to this file
min-font-pt = 10
max-words = 90
max-aspect-distortion = 0.02        # OVS202: share a picture may be stretched
max-bullets = 4                     # items at one level of one list
max-bullet-lines = 2                # rendered lines per bullet
max-bullet-depth = 2                # outline levels a list may use
max-font-families = 2               # typeface families across the deck
min-reading-order = 0.0             # Kendall's tau of reading order against layout (-1 to 1)
align-tolerance-pt = 4              # OVS005: edges this close count as lined up
min-balance = 0.05                  # OVS006: Ngo et al.'s balance measure, 0-1
min-whitespace = 0.25               # OVS007: share of the slide left empty
clutter-spread = 3                  # OVS008: MADs above the deck's median edge density
max-background-busyness = 0.19      # OVS009: edge density behind text
min-title-ratio = 1.0               # OVS111: title size over the largest other text
min-contrast = 4.5                  # body text (WCAG 2.2 AA)
min-contrast-large = 3.0            # 18pt and up, or 14pt bold
tolerance-pt = 2.0
render = true
render-as = "powerpoint"            # or "libreoffice": don't freeze shrink-to-fit
vision = false
vision-model = "openai:gpt-6-luna"  # provider:name, see Vision rules
vision-threshold = 0.7              # minimum probability to report
vision-brief = "House style the reviewer should know."
```

`examples/brand.toml` is a small example: one font, a five-colour palette, and a vision brief.

## Development

```console
uv sync
uv run pytest -q --cov     # integration tests skip without LibreOffice
uv run ruff format src tests scripts
uv run ruff check src tests scripts
```

To see what the rules do on real decks, fetch the starter corpus (63 openly licensed decks, about
190 MB, never committed) and run overset over it; see [docs/corpus.md](docs/corpus.md):

```console
uv run --group corpus scripts/fetch_corpus.py
uv run scripts/run_corpus.py
```

To measure the rules, [docs/labelling.md](docs/labelling.md) labels corpus slides and scores overset's
precision and recall against them, and [docs/rank-eval.md](docs/rank-eval.md) checks overset's findings
against people's rankings of AI-made decks.

See [CONTRIBUTING.md](CONTRIBUTING.md). MIT licensed.
