# Research-evaluation v2

A separately versioned evaluation suite for the Evidence Workbench. **Version 1 is not
replaced.** Its fixtures, identifiers and published failures are still in
[`data/research/v1/`](../v1/README.md) and still generated by
`scripts/evaluate-research.js`. v2 adds tasks, material and controls beside them.

Generate with `node scripts/evaluate-research-v2.js`; check with `--check`.

**What `--check` actually guarantees**, because overstating it would be the same mistake
this suite exists to avoid:

- **Exactly:** every structure, identifier, count, denominator, boolean and exact-recovery
  outcome — 0 exact recoveries of 39, 39 of 39 known-key applications, relabelling
  invariance for both solvers, every segmentation oracle agreement and cutoff flag, and
  every language decision and control.
- **Within 5 × 10⁻³:** aggregate means and extremes.
- **Within 0.35:** one item's own search error rates.
- **Not compared:** runtime and heap.

The per-item slack is not laziness. `Math.exp` and `Math.log` are implementation-defined in
ECMAScript, so two conforming engines may differ in the last bits; one annealing
accept/reject flips on that and the rest of that run takes a different path. This was found
the honest way — the suite passed locally and failed in CI at 74.8% against 74.9%. A
stochastic search is not bit-portable, and claiming otherwise would be false. **The
conclusions rest on the exactly-compared outcomes, not on any single trajectory.**

## Why six tasks and not one number

These six questions are routinely reported as if they were the same question. They are not,
and a system that does well on one can be useless at another.

| Task | The question it answers |
| --- | --- |
| Independent-key recovery | One ciphertext, one key drawn for it alone. How much plaintext and key comes back? |
| Fixed-code-pool recognition | One global code pool reused across texts. Is this cryptanalysis, or recall of a map already seen? |
| Authentic known-key replay | A published key along a published route. Does the mechanism reproduce? |
| Transcription | How many glyphs are wrong, and how many are unresolved? Reported apart from plaintext error. |
| Numerical segmentation | Where do the boundaries fall, and how many readings survive? Boundary error is not plaintext error. |
| Language and historical-domain shift | Which language profile fits, and when should the comparison decline to choose? |

## Split and grouping rules, audited on every run

Declared in [`scripts/research-splits.js`](../../../scripts/research-splits.js) and checked
by `tests/test-research-evaluation-v2.js`, which asserts that the rules actually reject the
leakage they describe:

- **Source grouping.** Every ciphertext variant derived from one source plaintext stays in
  one split. Variants of one text are not independent items.
- **Disjoint key seeds.** Each split draws key seeds from its own numeric range, so a seed
  can never appear on both sides.
- **Disjoint code pools.** The fixed-pool task draws its pools from per-split ranges. A pool
  shared across splits would turn recognition into memorization.
- **Collection-level assignment.** Splits are assigned per collection, so a whole body of
  material can be held out.

The only `development` collection is the set of probes the language-profile abstention
thresholds were calibrated on. Nothing else was tuned against anything.

## Material and rights

- **Museum-authored prose** (`data/research/v2/corpus.json`): original English and French
  written for this repository. `letter-a`, `letter-b` and `language-shift` are the v1
  fixtures, retained so their failures remain the baseline; `letter-c` is new in v2.
- **Held-out historical passages** (`data/research/v2/holdout.json`): extracts from the
  pre-1800 public-domain works used to build the language profiles, reserved *before*
  counting so the model has not seen them. Same works and same authors — a document-internal
  holdout, **not** an independent source document.
- **Authentic Z340 first section** (`data/research/v1/z340-section-1.json`), unchanged.

**None of this is a blind benchmark.** Every fixture, key and seed is visible in a public
repository, and renaming a file does not change that.

## Measured results

39 items at the published budget (seed 41, 6,000 annealing steps, beam width 150, 26-way
branching), 13 source documents, all in the `test` split.

### What 0 of 39 actually means

The headline below is that neither solver recovered any of these texts. That number is
easy to misread in two opposite directions, so here is the plain reading.

**It does not mean the solvers are broken.** The same annealing code applies a complete
known key correctly on all 39 items, and relabelling every symbol leaves its output
unchanged. The machinery works; it is the recovery problem that is not being solved.

**It also does not mean "nearly there."** At roughly 75% mean plaintext error, about three
characters in four are wrong. These are not almost-readable texts with a few slips — they
are wrong.

**The reason is the size of the problem relative to the evidence.** Each item is 120–343
symbols long and its key has 32–61 distinct symbols to pin down: about **5 observations per
unknown** on average, as few as 3. Every letter has two or three interchangeable codes, so
repetition — the thing frequency analysis lives on — is deliberately spread thin. A general
English quadgram model asked to choose among that many unknowns, from that little text, has
very little to go on. Short homophonic texts are hard for a reason that has nothing to do
with implementation quality, and historical cryptanalysts met the same wall.

What would change it is more text, a language model matched to the actual language and
period, or outside evidence — a crib, a known correspondent, a partial key. That is exactly
why the workbench is built around evidence and hypotheses rather than around a solve button.

### Independent-key recovery — both solvers fail, and that is the result

| Solver | Mean plaintext error | Mean key error | Exact recoveries | Mean runtime |
| --- | --- | --- | --- | --- |
| Simulated annealing | **74.9%** (41.9–83.3%) | 91.3% | **0 of 39** | 60 ms |
| Beam search | **79.1%** (62.5–83.7%) | 93.2% | **0 of 39** | 1,256 ms |

Beam search is both worse and about twenty times slower here. It is retained as a
comparison baseline, not as an improvement. Under identical inputs, language resources and
assistance, **neither solver recovered any of these texts.** The published v1 numbers
(33.2%, 46.0% and 73.3% on longer texts at a 15,000-step budget) remain the baseline and
are not superseded by these.

Two invariants hold for both solvers on all 39 items: applying the complete known key is
**exact 39 of 39**, and relabelling every symbol leaves the search outcome unchanged.

### Tuning sweep: can beam search be made to win?

Short answer: no, not with these two knobs. The grid, budget and win condition were fixed in
the header of [`scripts/sweep-solvers.js`](../../../scripts/sweep-solvers.js) **before any
result was read** — 4 beam widths x 3 scoring weights, plus annealing at two budgets under
the same three weights, one run per cell on the 13 `full-2hom` items. Beam search was
declared the winner only if some cell beat the shipped annealing row on mean plaintext error.

| Solver | Beam | Steps | Penalty | Plaintext err | Key err | Exact | Mean ms |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Annealing | — | 6,000 | 0 | **72.9%** | 89.2% | 0/13 | 31 |
| Annealing | — | 50,000 | 0 | **65.6%** | 80.7% | 0/13 | 186 |
| Beam | 50 | — | 0 | **80.1%** | 94.4% | 0/13 | 189 |
| Beam | 150 | — | 0 | **79.3%** | 93.7% | 0/13 | 592 |
| Beam | 400 | — | 0 | **79.7%** | 94.5% | 0/13 | 1,607 |
| Beam | 1000 | — | 0 | **76.7%** | 92.0% | 0/13 | 4,019 |
| Annealing | — | 6,000 | 1.5 | **71.9%** | 90.4% | 0/13 | 32 |
| Annealing | — | 50,000 | 1.5 | **57.6%** | 72.5% | 0/13 | 179 |
| Beam | 50 | — | 1.5 | **79.3%** | 94.9% | 0/13 | 134 |
| Beam | 150 | — | 1.5 | **78.6%** | 93.2% | 0/13 | 416 |
| Beam | 400 | — | 1.5 | **79.0%** | 94.5% | 0/13 | 1,151 |
| Beam | 1000 | — | 1.5 | **78.7%** | 92.3% | 0/13 | 2,978 |
| Annealing | — | 6,000 | 3 | **71.7%** | 89.6% | 0/13 | 25 |
| Annealing | — | 50,000 | 3 | **56.4%** | 72.7% | 0/13 | 179 |
| Beam | 50 | — | 3 | **80.5%** | 97.1% | 0/13 | 132 |
| Beam | 150 | — | 3 | **79.0%** | 93.8% | 0/13 | 425 |
| Beam | 400 | — | 3 | **77.8%** | 93.1% | 0/13 | 1,159 |
| Beam | 1000 | — | 3 | **78.1%** | 92.1% | 0/13 | 2,990 |

**Every annealing cell beats every beam cell.** The best beam configuration (width 1,000,
penalty 0) reaches 76.7% against the shipped annealing row's 71.9% — while taking 4,019 ms
against 32 ms, about 126 times the work. Widening the beam from 50 to 1,000 buys at most a
few points and not monotonically; the scoring weight moves things less than the gap between
adjacent beam widths. Beam search is kept as a disclosed contrast, not as an alternative to
reach for.

One finding about the *other* solver fell out of the same grid: annealing at 50,000 steps
with penalty 3.0 reaches **56.4%**, well below the shipped 6,000-step row's 71.9%. That is a
tuning observation, not a change — the published v2 results keep the 6,000-step budget so
the numbers stay comparable, and retuning the shipped budget would be a separate experiment
needing its own held-out material. Still 0 exact recoveries in all 18 cells.

Caveats are recorded in the file: 13 public fixtures, one run per cell, annealing is
stochastic and a different seed would move its numbers, and only two knobs were swept — a
different partial scoring function or extension order is a different experiment.

### Fixed-code-pool recognition — a different task

Applying a code pool already held: **exact on 13 of 13**. Recovering the same pool from one
short text: **72.8% mean plaintext error**, 87.4% key error, with each text exercising on
average 75.7% of the pool's symbols. A method trained on a shared pool is being measured on
recall, not on independent cryptanalysis.

### Numerical segmentation — verified against an exhaustive oracle

All five single-line cases match an independent exhaustive enumeration, and the three with
a hand-computed expected answer match that too. Ambiguous `2228` yields `AAAD`, `AND`,
`NAD`; one locked boundary removes `NAD`; a key missing a needed code yields nothing and
says so. Null codes, multi-reading word codes and line boundaries are carried as typed
entries, and line breaks are mandatory cuts that no code may span.

Boundary error is reported apart from plaintext error: reading `2|22|8` as `22|2|8` moves
**one** boundary and changes **two of three** letters.

Twenty repeated digits under `{2, 22}` admit 10,946 complete paths. At a 1,000-node budget
the lattice falls back to bounded k-best, retains 32, and reports
`globalBestGuaranteed: false` with the reason. **Pruning removes the guarantee, and the
result says so rather than implying a best answer.**

### Language and historical-domain shift

All **9 of 9** held-out passages were decided, and all 9 correctly, three per profile. All
three controls behaved correctly: English — which has no profile — was **abstained on**;
museum-written modern French ranked the French profile first, which is right about the
language and silent about the period; random letters were abstained on.

Nine passages from three works is a small measurement, and these passages share authors and
works with the training material.

#### Author-disjoint holdout — the stronger test

The set above reserves text from the *same* works by the *same* authors. A second holdout
removes that overlap entirely: three passages per language from authors and works that
appear **nowhere** in training. The disjointness is asserted when the file is built, so a
future edit that reused a training author fails the build instead of quietly inflating a
score.

| Profile | Author-disjoint source | Correct | What shifts |
| --- | --- | --- | --- |
| `historical-french-1580` | Pierre de Bourdeille, seigneur de Brantôme, Vies des dames | 3/3 | Different author, same language and century as the training text, memoir rather than essay |
| `historical-italian-1320` | Niccolò Machiavelli, La mandragola, La Clizia and Belfagor | 3/3 | Different author, two centuries later than the training text, and dramatic prose rather than verse |
| `historical-latin-classical` | Marcus Tullius Cicero, Orations | 3/3 | Different author, same century and language as the training text, forensic oratory rather than campaign commentary |

**Result: 9 of 9 correct, 0 abstentions**, with margins from 1.53 to 2.75 — the same
outcome as the document-internal set, on harder material. Every language in the profile set
has usable author-disjoint text, so there is no language to report as uncovered here.

Two honest qualifications. Three passages per language is still a small measurement, not an
accuracy figure. And the shifts are not equal: Brantôme is the same language and century as
Montaigne, Cicero the same century and language as Caesar, while Machiavelli is two
centuries later than Dante and prose rather than verse — the Italian row is doing the most
work, and it is the one with the narrowest margins.

**Source review, 4 November 2026:** the first excerpt in each author-disjoint file
contains edition front matter or introductory prose. The French excerpt includes
publisher material; the Italian excerpt is an editor discussing a 1912 edition and
modernized spellings; the first Latin excerpt is third-person introductory prose
whose authorship and period the fixture does not establish. The published **9/9**
still describes language ranking of those nine committed strings, but it must not be
read as nine verified passages of historical author prose. The separate
[historical-profile recovery experiment](../profile-recovery-v1/README.md) excludes
all three first excerpts before search, records that selection, and uses passages
2–3 from each source. Excluding the Italian preface does not undo the edition's
orthographic changes. The earlier fixtures and recorded outcomes remain available.

**Unresolved coverage:** German, Spanish, English and every other language in the historical
record have no profile. A text in one of them can only be abstained on or mis-assigned. This
is a gap in the *profile set*, not in the holdout: every language that does have a profile
also has author-disjoint held-out text.

## Limits

- Held-out passages are not independent source documents.
- Budgets are small enough to run in the test suite on every change. A larger budget is a
  separate experiment; it would not change which task is which.
- Runtime and heap figures are Node.js measurements around single calls, not peak resident size.
- Per-item search numbers are reproducible on one machine, not bit-portable between engines. See the `--check` guarantee above.
- A score is never a probability that a reading is historically correct.
