Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions .claude/skills/tetrak-articles/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ EasyOCR model. Reference material belongs under `site/content/reference/` and
research under `site/content/research/` — an article argues, it does not
document.

Drafts and proposals live in the private `tetrak-product` repository
(`product/articles/`); publishing one is a copy into `site/content/articles/`
here. Never link a published article back to a draft.

## Creating one

```bash
Expand Down Expand Up @@ -70,12 +74,17 @@ unreadable; an absolute one breaks the day the site is served from a
subdirectory; and relref resolves through the page, so a moved target **fails
the build** instead of publishing a 404.

## Numbers stay in the research pages

The research pages read their figures from `evaluation/ocr/benchmark.csv` at
build time and so cannot disagree with the harness. An article may point at a
figure and argue about what it means; it must **not** carry a transcribed copy
of one.
## Numbers stay in the data

Figures come from the harness's own output, read at build time:
`evaluation/ocr/benchmark.csv` for the corpus (`{{< benchmark >}}`) and
`evaluation/ocr/registers.csv` for the Armenian registers
(`{{< registers >}}`, `{{< registers metric="chr" >}}`). An article may embed
those tables, point at a figure and argue about what it means; it must **not**
carry a transcribed copy of one. That includes counts derived from the tables
("leads on five of eight registers") and figures from a research note ("fixed
465 words"): say "most registers" or "many times more than it broke", and let
the table carry the number.

This is not a style preference. The slide deck carried transcribed numbers and
disagreed with the harness within a fortnight — nothing failed, and nobody
Expand Down
68 changes: 53 additions & 15 deletions .claude/skills/tetrak-corpus/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,45 +25,83 @@ $EDITOR evaluation/ocr/corpus/SOURCES.md
# 3. ground truth
python tools/generate_expected.py --fixture evaluation/ocr/corpus/images/<name>.<ext>

# 4. site renditions (committed, not built — see below)
# 4. classify it: which band fit may learn from it, and whether the site shows it
$EDITOR evaluation/ocr/corpus/splits.toml # [excluded] until a split is designed

# 5. the Tesseract gate: does CI hold it to the thresholds?
$EDITOR tests/ocr/test_thresholds.py # KNOWN_TESSERACT_LIMITATIONS unless it clears both

# 6. site renditions (committed, not built — see below)
python tools/generate_corpus_thumbnails.py

# 5. a card on the corpus page
# 7. a card on the corpus page, if it is in [published]
$EDITOR site/content/reference/corpus.md # add a {{< lightbox >}} entry

# 6. re-measure
# 8. re-measure
tetrak-ocr evaluate --all --save
```

Commit the image, its `expected/` transcript, the SOURCES.md entry, the
renditions, the corpus page card, and the regenerated benchmark together.

## The two steps that fail silently

**Thumbnails (4) and the corpus card (5).** The renditions are committed
`splits.toml` and threshold-test entries, the renditions, the corpus page card,
and the regenerated benchmark together.

## The steps that fail silently, and the ones that fail loudly

**`splits.toml` (4) fails loudly**, on purpose: `tests/ocr/test_calibration.py`
asserts that every split accounts for every fixture, so an unclassified scan
fails CI. Put a new one in `[excluded]`; folding it into a split's fit or
held-out set is a decision about the band fit, not housekeeping.

`[published]` in the same file records which scans the site is *meant* to
show, but nothing reads it except a check that its names exist: the harness
scores every fixture with ground truth, and the benchmark table renders every
row, so a new scan appears in the results as soon as step 8 runs. What you do
control is the corpus page card (7).

**The threshold test (5) fails loudly too.** A fixture *absent* from
`KNOWN_TESSERACT_LIMITATIONS` is one CI holds to both thresholds, and the band
fitter treats that as a hard constraint. List it on arrival, as the file's own
comment explains, and take it off once the measurement says it clears both.
The fitter keeps its own copy of the gated set, `CI_GATED` in
`evaluation/ocr/calibration/fit.py`, and `test_calibration` fails until the two
agree, so change both together. Changing which fixtures are gated changes the
fit's constraints: re-fit afterwards (below).

**Thumbnails (6) and the corpus card (7).** The renditions are committed
rather than built, so a new item is simply *missing* from the corpus page
until both are done. Nothing errors; the grid is one entry short and looks
entirely normal.

**SOURCES.md (2).** Nothing enforces it, and an image whose rights are not
**SOURCES.md (2) fails silently.** Nothing enforces it, and an image whose rights are not
recorded cannot be published — which is discovered much later, by someone who
has to work out where it came from.

## Re-check the Tesseract auto-configuration bands

`analyse_image()` picks contrast and PSM from pixel statistics, and its
thresholds in `src/tetrak_ocr/backends/tuning.py` were **fitted to part of
this corpus** — `FIT_PROVENANCE` in that module records exactly which images,
and which were not.
this corpus**: the split named in `FIT_PROVENANCE` in that module, defined in
`splits.toml`.

If the corpus changes materially, re-fit them with the calibration toolkit
under `evaluation/ocr/calibration/` rather than editing the numbers by hand.
rather than editing the numbers by hand. All three steps write committed
files, and each needs its flag or it only prints:

```bash
python -m evaluation.ocr.calibration.features --write # pixel statistics; a new raster needs this first
python -m evaluation.ocr.calibration.sweep --save # re-measure every configuration
python -m evaluation.ocr.calibration.fit --write # regenerate the bands in tuning.py
```

Skip `--save` and `fit --write` re-fits the old measurements, and CI's
`fit --check` still passes. A corrected transcript invalidates only that
fixture's sweep rows: `sweep --fixture <stem> --save`, then `fit --write`.
Left un-refitted, `tesseract-auto` quietly becomes miscalibrated: it keeps
working, and merely gets worse.

**Do not fold held-out fixtures into a re-fit without saying so.** The images
added after the original fit are held-out data for `tesseract-auto` and
nothing special for any other backend. A band set scored only on the images it
**Do not fold held-out fixtures into a re-fit without saying so.** A split's
held-out fixtures are held-out data for `tesseract-auto` and nothing special
for any other backend. A band set scored only on the images it
was fitted to tells you nothing about whether it generalises — that property
is worth more than the accuracy it costs.

Expand Down
56 changes: 20 additions & 36 deletions .claude/skills/tetrak-ocr-design/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ layouts in `site/layouts/`, styles in `site/assets/scss/`, pages in
`site/content/`. There is no `themes/` directory and no external theme. Every
npm command below is run from `site/`.

The Python package it documents sits at the repository root. The two files the
site reads from there — `evaluation/ocr/benchmark.csv` and `LICENSING.md` — are
mounted into Hugo's assets by `[module.mounts]` in
`site/config/_default/hugo.toml`, because `os.ReadFile` cannot see above the
project root. Anything else the site needs from the repository needs a mount
The Python package it documents sits at the repository root. The files the
site reads from there — `evaluation/ocr/benchmark.csv`,
`evaluation/ocr/registers.csv` and `LICENSING.md` — are mounted into Hugo's
assets by `[module.mounts]` in `site/config/_default/hugo.toml`, because
`os.ReadFile` cannot see above the project root. (The band table's data is
different: `tools/generate_tuning_data.py` writes `site/data/tuning.toml`
during `prebuild`.) Anything else the site needs from the repository needs a mount
too; that is deliberate, since it keeps the reach declared in one place.

## Provenance, and one thing not to undo
Expand Down Expand Up @@ -214,18 +216,9 @@ is the one part of the site that is dated and signed, but it is not a second
design: it opens with the same kicker, `h1` and standfirst as every other page,
and everything it adds is apparatus rather than decoration.

Files live at `site/content/articles/<year>/<month>/<YYYY-MM-DD>-<slug>.md` and
publish flat at `/articles/<year>/<month>/<slug>/`. **The date directories are
not sections** — they hold no `_index.md`, so nothing renders at
`/articles/2026/`, and giving one an `_index.md` would publish a second,
unstyled index of the same articles.

The URL is built from front matter, not from the path. **Year and month come
from `date`**, so a file misfiled by a month still publishes correctly. **The
last segment comes from `slug`, which falls through to the title when empty** —
not to the filename, which is what it looks like it does when the file is named
after its title. A sentence-length title becomes a sentence-length URL unless
`slug` is set; the archetype carries an empty `slug` as the reminder.
Where files go, how the URL is assembled, front matter, relref linking and the
rule against transcribed numbers are content rules: load the `tetrak-articles`
skill for those. What follows is the design side.

Layouts are `layouts/articles/list.html` and `layouts/articles/single.html`;
both listings — the index and the tag pages — render
Expand Down Expand Up @@ -269,25 +262,16 @@ instead — an empty tag index in place of the article list, with a green build.
`_default/list.html` and `_default/single.html` still work where they are, which
is what makes this easy to get wrong.

### Linking from an article

Use `{{< relref "/path" >}}`, not a relative or absolute path. An article sits
four directories deep, so a relative link is unreadable, and an absolute one
reopens [the baseURL trap](#linking-and-the-baseurl-trap) below. relref resolves
through the page, so a moved target fails the build.

Numbers stay in the research pages, which read them from
`evaluation/ocr/benchmark.csv`. An article may point at a figure and argue about
what it means; it must not carry a transcribed copy of one.

## Shortcodes

| Shortcode | Usage |
|---|---|
| `{{< figure src="design/x.png" alt="…" caption="…" class="…" >}}` | Image through the asset pipeline. `src` is relative to `site/assets/images/` |
| `{{< figure src="design/x.webp" alt="…" caption="…" class="…" >}}` | Image through the asset pipeline. `src` is relative to `site/assets/images/` |
| `{{< figure-themed src="evaluation/benchmark-comparison" alt="…" >}}` | Light/dark pair, so a chart drawn on white does not glare on a dark page. `src` is the **base name**; it resolves `<src>-light.png` and `<src>-dark.png` |
| `{{< lightbox src="corpus/name" alt="…" title="…" width="170" >}}` | Corpus thumbnail linking to its large rendition. Resolves `<src>.webp` and `<src>-large.webp` |
| `{{< benchmark >}}` / `{{< benchmark metric="sec" >}}` | The results table, read from `evaluation/ocr/benchmark.csv` at build time |
| `{{< benchmark >}}` / `{{< benchmark metric="sec" >}}` | The corpus results table, read from `evaluation/ocr/benchmark.csv` at build time |
| `{{< registers >}}` / `{{< registers metric="chr" >}}` / `{{< registers view="summary" >}}` | The Armenian per-register table, read from `evaluation/ocr/registers.csv`. `bold-best="false"` drops the best-in-column marking |
| `{{< bands >}}` / `{{< bands setting="psm" >}}` / `{{< bands provenance="true" >}}` | The Tesseract auto-configuration bands, read from `site/data/tuning.toml` |
| `{{< note kind="warning" title="…" >}}…{{< /note >}}` | An admonition. `kind` is `note`, `warning` or `caution`; `title` optional |
| `{{< tabs >}}{{< tab "macOS" >}}…{{< /tab >}}{{< /tabs >}}` | Tabbed content. The tab label is a **positional** argument |
| `{{< include "LICENSING.md" >}}` | Inlines a file from the repo — positional, repo-root relative |
Expand All @@ -302,10 +286,10 @@ full URL passed as `linkedin` — the host is built in the template, because a
URL in a shortcode attribute trips markdownlint's MD034 and switching that rule
off would stop it catching bare URLs in the prose it is actually for.

**Three of these are partials with a shortcode wrapper**, because a layout
**Several of these are partials with a shortcode wrapper**, because a layout
cannot call a shortcode and the walkthrough needs the same markup:
`partials/benchmark.html`, `partials/lightbox.html` and
`partials/figure-themed.html`. They take a dict rather than shortcode
`partials/benchmark.html`, `partials/registers.html`, `partials/bands.html`,
`partials/lightbox.html` and `partials/figure-themed.html`. They take a dict rather than shortcode
arguments; the shortcode is a two-line wrapper that builds it. Change the
partial, not the wrapper. `partials/walkthrough-scores.html` is the one that
has no shortcode — it only ever had one caller.
Expand Down Expand Up @@ -379,9 +363,9 @@ defect is reintroduced.
- Sentence case headings.
- Write for a competent developer who has already hit the problem. Depth beats
brevity; there are no word limits.
- Claim nothing the benchmark does not show. Where a number is published, it is
derived from `evaluation/ocr/benchmark.csv`, not transcribed — the table shortcode
reads the CSV so the page cannot disagree with the data.
- Claim nothing the data does not show. Where a number is published, it is
read from `benchmark.csv`, `registers.csv` or `tuning.toml` by a shortcode,
never transcribed, so the page cannot disagree with the data.
- `claude` is a **ceiling reference**, not a competitor: it generated the ground
truth everything else is scored against. Mark it as such and exclude it from
"best local".
Expand Down
Loading
Loading