Skip to content

Spec 001 T035: compare - #167

Closed
adamjohnwright wants to merge 4 commits into
mainfrom
t035/compare-2
Closed

adamjohnwright wants to merge 4 commits into
mainfrom
t035/compare-2

Conversation

@adamjohnwright

Copy link
Copy Markdown
Contributor

Spec 001, task T035. Replaces #165 after its review (two highs, three mediums, fixed in the second-last commit).

Everything in #165 (pdf-export compare, FR-012's parts), plus, from #165's review, one governing rule: nothing read from a PDF is printed unless it has a known shape (a count, yes/no, a release, an item of a fixed list, a stable identifier, a valid analysis token, one of Reactome's species); everything else is a hash (salted per run) and a length, enforced by one printer (src/compare/output.ts) and a fuzz-like test planting names after every label in 300 random layouts per side.

  • The cover title (which a figure could swallow, leaving the names line as "title") is never printed: compared as a hash, reported same/differs against its file name.
  • Analysis values (which could capture summation lines) end at the first stable identifier or heading and are kept only in their shape.
  • A contents target unread on either side is a difference; order is by longest common subsequence, repeated sections compared occurrence by occurrence; reduction indexed by page (4,000 sections: 1.25 s, was 30.9 s); an unreadable file is reported and the rest compared; --expected refuses unknown keys and lists unmatched records; --reference-margin for T040.

Tests: test/compare/ (37), including a second reference layout built differently; 38 mutants, all caught. Open for T040: event-pdf's real labels and margins; our analysis part doesn't print its resource.

🤖 Generated with Claude Code

adamjohnwright and others added 4 commits November 4, 2026 05:40
pdf-export compare <reference> <new> [--expected <file>], as contracts/cli.md
has it: each side a PDF or a folder, a folder compared file by file by name.
Both sides are read with pdf.js (lines, links, figures as clusters of images
and painted paths) and reduced to FR-012's parts: the cover's title, diagram,
excerpt note and distinct names (counted and hashed; U+2060 and no-break
spaces normalised); the introduction's release and counts; the analysis's
properties; each section's parts by their labels and their text; the
contents' entries and targets; each figure's kind. The literature and edit
history, which name people, are held as hashes. The JSON report gives each
difference by part, field and kind with a count and stable identifiers, list
order as a kind of its own; no section text and no name is printed.
--expected takes the recorded differences, with their reasons.

Tests print a sample document with pdf-export's layout and as a reference
in event-pdf's shape (placeholder names, wording written anew): each part's
difference is caught, and no name appears in any report. 21 mutants, each
caught.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t strict shapes

One printer (src/compare/output.ts) every reported value passes through:
text read from a PDF is printed only as a count, yes or no, a release, one
of a fixed list, a stable identifier, an analysis token of the service's
form or one of Reactome's species; anything else as a hash and a length,
salted once a run. Tested with names planted everywhere in 300 random
layouts a side.

- H1: the cover title is a hash, said only to be its file's name or not.
- H2: the analysis part ends at the first stable identifier or heading,
  and a property is kept only of its shape.
- M1: a contents target not read on either side is missing-target.
- M2: links, figures and targets read by page; 4,000 sections in 1.25 s
  (30.9 s before on the same layout); a file's bytes not copied twice.
- M3: the sections' order by their longest common subsequence, each
  occurrence of a repeated section compared with its own.
- Lows: --reference-margin; an unreadable file named and a difference;
  --expected refuses unknown keys, keeps an events record to differences
  with events, and lists records matching nothing; docs say what is done.

A second reference layout, unlike the sample's, found that a thin
connector must join a vector figure's shapes. 38 mutants, all caught.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adamjohnwright

Copy link
Copy Markdown
Contributor Author

Replaced after review: pdf.js warnings could print PDF text on stderr; a shaded table header joined its grid into a 'figure'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant