Skip to main content
Glama
README.md
# parallax

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.24793870.svg)](https://doi.org/10.5281/zenodo.24793870)

Two independent readers extract every printed value from a paper, and a reviewer settles each place where they
disagree on the page image. parallax keeps the readers apart, compares their readings, and follows every paper and
every disagreement in a ledger until it is concluded. The settled disagreements become new prompt rules, so the next
paper's readers disagree less.

Named for the shift between two views of one object: the readings are the two views, and their difference is what
gets measured.

It grew out of the extraction of measured values from original papers on oxide thermochemistry for ORCHID, the open
CALPHAD database project at Texas A&M University (2026), where the rules were written for thermodynamic values.
Most of them hold for any printed number (copy exactly, read from the page image, keep a value with its uncertainty, a
range is one row), and the prompt will be split into a general reading core and a short domain profile.

## How it works

1. **Two readers, kept apart.** Each reader (an AI agent) gets a sealed packet with one paper and the prompt, and
   nothing else. It views every page as an image and writes one row per printed number.
2. **A checker tests each reading against the PDF.** It is a program, not a judgement: the quote must be on the page,
   the number in the quote, the digits as the page prints them, and an uncertainty printed beside a value must be in
   its row. A reading is handed in only with 0 errors.
3. **The readings are compared.** Rows are paired by page and printed number; every value one reader has and the
   other lacks, or reads differently, becomes a disagreement.
4. **A reviewer settles every disagreement on the page image.** The ledger records the verdict (reader A, B, both or
   neither), the cause (reader slip, unclear rule, text layer, misprint in the paper, pairing artifact) and who decided.
   A paper is filed only when nothing is left open.
5. **Unclear rules become new rules.** Where both readers followed the prompt and the prompt allowed both readings, the
   reviewer writes a numbered rule, and the next paper cannot be packed until that is done.

**What the rules extract.** The bundled prompt (rules 1 to 182) is written for measured thermodynamic data in papers on
oxide chemistry: enthalpies of formation, heat capacities, entropies, solution enthalpies, transition temperatures. The
readers write every printed number, each measured result with its uncertainty and what the paper says that uncertainty
is, the conditions that go with it (temperature, pressure, solvent, sample composition), method details, and values
taken from other work (marked cited, with that work named). Each row keeps the value as printed, its kind (measured,
calculated, cited, method detail), the chemical system and phases, the place (page, table, figure) and a verbatim
quote. Most rules are about reading exactly rather than about chemistry, so a new profile can aim the same machinery
at other values.

**Who did what so far.** The reviewer role is built for a person. In the ORCHID rounds an AI reviewer (Claude Opus)
settled each disagreement on the page image under the researcher's oversight, and the ledger records who decided each
one. The readers were Claude Sonnet agents, and the prompt was refined for them.

**Models.** parallax-mcp speaks the Model Context Protocol, so any MCP-capable agent can drive it, and the command line
hands readers plain folders that any model or person can fill. A reader must read page images and work through a long
prompt until the checker reports 0 errors. The independence of the readings rests on the client too: the agent file
`.claude/agents/parallax-reader.md` gives a Claude Code reader the reader tools and nothing else, and another client
needs the same restriction so that a reader cannot open the other reading. Two readers from different models should
share fewer blind spots than two from one. Tested so far with Claude models only; the prompt and the checker can be
refined for other values and other models.

## Projects and extractor folders

```
python -m parallax setup
```

asks where projects should live (Downloads is offered, since PDFs usually arrive there), the project's name, the
name of its first extractor folder, and the prompt to start from (the bundled oxide thermochemistry prompt if none).
The location is kept in a settings file (`%APPDATA%\parallax\config.json`), so it is asked once.

```
Downloads\ORCHID\                      the project
    project.json
    prompt\PROMPT.md, example_rows.jsonl     one prompt for every extractor folder, refined by the loop
    prompt\history\, rules.jsonl             earlier prompts and the rules the loop added
    originals_extractor\                 an extractor folder
        papers\                          put PDFs here; paper_list.csv lists each with its fingerprint
        output\                          settled rows
        packets\, readings\, ledger.jsonl    the readers' sealed work, the comparisons, every step
    ree_extractor\                       another extractor folder, same prompt
```

A PDF is never copied. It is entered where it sits, in `papers\` or anywhere else by its path, with its sha256;
every read checks the fingerprint, and a moved or changed PDF is refused with its path named. An existing extraction
folder (a `paper_list.csv` and a `papers\` folder) can start an extractor folder: its PDFs are entered under their
own ids where they sit, and nothing is written into it.

```
python -m parallax new-extractor ORCHID ree [--from <existing extraction folder>]
python -m parallax --in ORCHID/originals add              every new PDF in papers\ (ids P001, P002, ...)
python -m parallax --in ORCHID/originals add <pdf> --id O074 --doi 10.xxx
python -m parallax projects
```

A folder made before projects existed (its own `prompt\` inside) still works on its own, with `--project <folder>`.

## How a paper moves

| Stage | What happens | Command |
|---|---|---|
| listed | the paper is entered | `parallax list O074` |
| packed | each reader gets a folder with only that paper and the prompt | `parallax packed O074 --reader A --prompt-version ...` |
| reading | the readers work, each unaware of the other | `parallax returned O074 --reader A --status done` |
| checking | each reading goes through the row checker until it has 0 errors | `parallax check FOLDER`, then `parallax checked` |
| settling | the readings are compared; every line that is not agreed is a disagreement | `parallax compare`, `parallax items`, `parallax settle` |
| learning | after filing, every disagreement settled as "rule unclear" gets a prompt rule or a reason for none | `parallax file`, `parallax rule` |
| concluded | nothing is left open | `parallax status` |

A paper may instead be dropped with a reason. The ledger (`ledger.jsonl` in the project folder) is append-only and is
replayed on every load, so a step cannot be skipped and a hand edit that breaks the order is refused. Each settlement
records the verdict (A, B, both, neither), the cause (rule_unclear, reader_slip, text_layer, pairing_artifact,
misprint), what was looked at, and who decided.

## Setup

```
conda create -n parallax -c conda-forge python=3.12 pytest
conda activate parallax
pip install -e .
python -m pytest
```

pymupdf comes from pip. On Windows with Smart App Control the conda-forge pymupdf DLL and the generated
`parallax.exe` launcher can be blocked; `python -m parallax ...` works in either case.

## parallax-mcp, the MCP server

Same design as orchid-mcp and orchid-sage: a small JSON-RPC server over stdio, no MCP SDK needed.

```
python -m parallax_mcp                      projects at the location in the settings file
python -m parallax_mcp --project <folder>   one standalone folder, the older way
```

Project tools: `setup_location` (the agent asks the user where, suggesting Downloads), `new_project` (asks for the
name), `new_extractor`, `list_projects`, `use_extractor`, `add_papers` (PDFs where they sit).

Reviewer tools: `status`, `add_paper`, `pack` (builds the two sealed packets and returns one key per reader),
`reopen_reading`, `compare`, `items`, `show_item` (both readers' rows and a crop of the page where each row's quote
sits), `settle`, `reopen`, `file_paper`, `drop`, `report`, and the refining loop below: `get_prompt`, `add_rule`,
`rule_outcome`, `scoreboard`.

Reader tools take a key and reach only that key's packet: `reader_brief` (the paper and how to work, then the
prompt as packed and its examples in parts of at most 24,000 characters, since a tool result over about 50 KB
reaches an agent only as a file it cannot open), `reader_page_image`, `reader_page_text`, `reader_write_rows`, `reader_fix_rows` (replace or delete rows by the
line number the check gives, all or nothing, rows renumbered after), `reader_read_rows`, `reader_write_misprints`,
`reader_check`, `reader_finish` (done needs 0 errors; partial needs a note; after it the rows are locked). Only a
key's hash is stored, and packing again issues new keys. The agent `.claude/agents/parallax-reader.md` is given the
reader tools and nothing else, so a reader cannot open files, the ledger or the other reading.

One paper, run from a Claude Code session with the server connected:
1. `use_extractor` (or `new_project`), `add_papers`, then `pack`. A reader's packet keeps the prompt as it was at
   packing.
2. Start two `parallax-reader` agents in parallel, each told only its key.
3. A reader that finished partial, or with errors it could not fix, is reopened with `reopen_reading` (before
   `compare` only): a new key for that reader, its own rows and finishing note, the prompt it was packed with. The
   reason stays in the ledger and is never shown to the reader, so the two readings stay independent.
4. `compare`, then for each item `show_item` and `settle`; write the settled file; `file_paper`.
5. For each disagreement settled as rule_unclear, `get_prompt`, then `add_rule` (or `rule_outcome` declined, with
   the reason). The next paper cannot be packed until this is done.
6. `report` writes `report.html` in the project folder: every paper's stage, disagreement per prompt version with a
   chart of its causes, the rules added and declined, and what is still open. From the command line:
   `python -m parallax report`.

## The refining loop

Each round should leave the readers less to disagree about. A disagreement settled as `rule_unclear` (both readings
follow the prompt, and the prompt allows both) is the kind a rule removes; a `reader_slip` is what two independent
readers are there to catch, and needs no rule.

- The loop is the project's: a rule from any extractor folder goes into the one project prompt, and every extractor
  folder waits for it.
- `add_rule` writes the next numbered rule into `prompt/PROMPT.md`, right after the last rule's own lines.
  A rule for something the comparison makes no item of (labels such as value_type, topic or source; rows the checker
  refused) gives a `basis` instead (the papers and rows it comes from), kept with it in `prompt/rules.jsonl`.
  It names the disagreements it settles, keeps the prompt before the change in `prompt/history/<version>.md`, logs
  the rule in `prompt/rules.jsonl`, and records the rule against each disagreement in the ledger. A rule naming an
  unknown, unsettled or already-answered disagreement is refused and changes nothing.
- `pack` refuses while any filed paper still has a rule_unclear disagreement without a rule or a declined reason, so
  the next round is always read with the refined prompt.
- `scoreboard` gives, per prompt version, the share of compared lines the readers disagreed on and the share that
  were rule_unclear. The loop works when that share falls from one round to the next.

The same from the command line: `python -m parallax add-rule O074-012 O074-015 --title "..." --text "..." --by Opus`
and `python -m parallax scoreboard`.

To connect the server to Claude Code, register it as an MCP server named `parallax-mcp` (for example
`claude mcp add parallax-mcp -- python -m parallax_mcp`) and copy `.claude/agents/parallax-reader.md` into
`~/.claude/agents/` or the project's `.claude/agents/`, so the reader agent exists.

## Contents

| Path | What is in it |
|---|---|
| `src/parallax/state.py` | the ledger: stages, events, refusals |
| `src/parallax/config.py` | the settings file: where projects live, names of projects and extractor folders |
| `src/parallax/project.py` | projects, extractor folders, PDFs in place, sealed packets and keys, the loop |
| `src/parallax/profiles/` | the bundled prompt, oxide thermochemistry (rules 1 to 182) |
| `src/parallax/compare.py` | pairs the two readings by page and printed number |
| `src/parallax/rows.py` | the row checker; it also runs on its own as `check_rows.py`, so it imports nothing from parallax |
| `src/parallax/report.py` | the one-page report |
| `src/parallax/cli.py` | the commands above |
| `src/parallax_mcp/server.py` | parallax-mcp |
| `.claude/agents/parallax-reader.md` | the reader agent |
| `examples/walkthrough.ipynb` | one round and a refined second round on a generated paper, with its outputs; rebuilt and run by `scripts/build_walkthrough.py` (needs `pip install -e .[notebook]`) |
| `tests/` | planted cases for the checker (on a generated PDF), the comparison, the ledger, the commands and the server |

## Status

Version 0.1.0 (2026-12). Used for ten rounds of the ORCHID originals extraction: 35 papers read by two independent
readers through parallax-mcp, every disagreement settled on the page image, the prompt refined from 112 to 182 rules
along the way. 98 tests, with planted faults for the checker, the fingerprint check, the packing block, the comparison
lock on reopening and the renumbering of fixed rows.

Next:
1. Split the prompt into a general reading core and domain profiles (oxide thermochemistry first). The rules were
   written for thermodynamic values, but most hold for any printed value.
2. Independence measures: reader variants (another model, page order, image first) and planted pages with known
   answers, to catch two readers agreeing on the same wrong value.

## Citation and license

Code is under the MIT license (`LICENSE`). The bundled prompt, the example rows and the outputs of the walkthrough
notebook are data, released under CC BY 4.0. Version 0.1.0 is archived on Zenodo, and `CITATION.cff` gives the same
citation (GitHub's "Cite this repository" button):

> Bustamante, M. E., & Arroyave, R. (2026). parallax: two independent readers and a reviewer for extracting printed
> values from papers (Version 0.1.0) [Software]. Zenodo. https://doi.org/10.5281/zenodo.24793870

The DOI 10.5281/zenodo.24793869 names all versions together and always resolves to the newest.