Skip to content

Latest commit

 

History

History
272 lines (228 loc) · 13.4 KB

reference.md

File metadata and controls

272 lines (228 loc) · 13.4 KB

Reference

How proofback works and what it promises: commands, exit codes, what import does with each kind of annotation, how a mark finds its source, the files it keeps, performance and accuracy. The interfaces that stay stable across 1.x releases are listed in stability.md.

Commands

Command Purpose
init Create .proofback/config.toml and the cache ignore rule
import <file> Import an annotated PDF, a notes file, a DOCX, or (with --ai) a photo of handwritten marks as a round
list Items as a table, --json, or --md (GitHub task list); filters by round, status, file and kind
show <id> One item with source context
triage Keyboard UI to confirm, resolve and reply
resolve <id> Set an item's status and add a reply
confirm <id> Accept the location of an item an AI model structured
suggest <id> Ask the configured AI model for a suggested edit (off by default, never applied automatically)
patch [ids] Unified diff for replace, delete and insert items
apply [ids] Write those edits (refused if the anchored text changed since import)
sync Re-anchor items to the current source
answer -o <pdf> The reviewer's PDF with a reply on every answered note
letter Response letter as LaTeX or Markdown; --diff-pdf <file> names a PDF with the changes highlighted (made by overfull diff)
inline Optional % proofback pb_xxx: comments or \todo{} in the source
docx export A DOCX with hidden source anchors for reviewers who use Word
sarif SARIF 2.1.0 for GitHub code scanning
stats Counts by round, status, file and reviewer
doctor Check SyncTeX, encodings and the project root; --pdf <file> lists the annotation types in a PDF
mcp Run the MCP server on stdio
schema Print the JSON Schema of round files
locate Map a PDF position to a source range, without a round (below)

Global flags: --project <dir>, --quiet, --color auto|always|never. Commands that print data take --json.

Exit codes

Code Meaning
0 Success
1 Something needs action: open items remain with --fail-on-open, or a doctor check failed
2 Usage error
3 Unreadable or invalid input
4 Refused write: the anchored text changed, an encoding cannot round-trip, or a path is outside the project

JSON output

Command JSON (--json and MCP results) carries tool, version and schema_version (currently 2). Round files keep their own schema_version 1. The location object, the top-level fields, the shared exit codes and the SARIF conventions are shared with overfull and specified in interop.md.

Locator

proofback locate --pdf <file> [--synctex <file>] --page <n> [--rect x0,y0,x1,y1] [--text <s>] [--json]

Or --stdin with one JSON query per line ({"page": 3, "rect": [x0, y0, x1, y1], "text": "..."}), which prints one JSON result per line. Rectangles are in PDF points with the origin at the bottom left. A result has file, line, column, end_line, end_column, confidence and reason; with confidence page it has no source fields.

The locator runs the same pipeline as import, so its confidence means the same. It is stateless: it reads only the sources under --project (or the current directory) and never reads or writes .proofback/. Queries are bounded: 100,000 per call, 4,096 characters of text, 64 MB of input. Queries with text work without PDFium; without SyncTeX the search uses the text alone. Exit codes: 2 for a malformed command line, 3 for an unreadable PDF or SyncTeX file or an invalid query line. The same API is in the Node package (require('proofback').locate). Schema: locate-v1.json.

PDF annotations

What import does with each annotation subtype. A test in crates/proofback-cli/tests/e2e.rs checks this table and the one in README.md against the code.

Subtype Result Kind and location
Highlight item highlight, or comment / question with a note; exact range
StrikeOut item delete, replace, comment or question; exact range
Underline item like Highlight
Squiggly item like Highlight
Caret item insert with text, else comment; insertion point
Text item sticky note: comment or question; the line beside it
FreeText item comment or question; the line beside it
Ink item handwritten mark: comment, body (handwritten mark) without a note; the lines it covers, at best line; strokes close together merge into one item
Square item general (figure on a figure or table); the text inside it
Circle item like Square
Line item general; the text under it
Polygon item general; the text inside it
Stamp item general; the line beside it
FileAttachment item general; the line beside it
Link skipped links, not reviewer marks; counted in the import summary
Widget skipped form fields; counted in the import summary
Sound item voice note: general; the line beside it (the audio is not played or transcribed)
Watermark skipped counted in the import summary
Others (Screen, PrinterMark, TrapNet, 3D, RichMedia) skipped counted in the import summary
Popup not counted the window of another annotation's note, read with it

Handwritten marks: strokes on one page by one author whose boxes are closer than 12 pt form one item. The item points at the source lines under its box, or beside it for a margin mark, through SyncTeX when present. It is never exact; it is page when the box covers more than 6 text lines, or sits in the margin with no text beside it. There is no handwriting recognition and no model.

Annotations are read with lopdf; the text under them comes from PDFium's per-character boxes, so it is known even when the annotating application did not store it. Without PDFium, import falls back to the text stored in the annotations.

How a mark finds its source

Precision comes before recall: a wrong confident location costs more than an honest "page only". Every step may lower the confidence; none may raise it without evidence.

For each annotation:

  1. Extract the type, page, quads or rectangle, note, author, date, colour, /NM and replies.
  2. Read the marked text under the quads plus about 80 characters of context on each side, undoing hyphenation at line ends.
  3. Coarse location. SyncTeX inverse search for each quad gives a ranked set of (file, line) candidates. Point annotations use the nearest text line.
  4. Fine location. The candidate lines and a margin are normalised (macros, accents, ligatures, references and inline maths) and the marked text is aligned against them, with its context. The hit maps back to a source byte range.
  5. Classify as comment, question, delete, insert, replace, highlight, figure, math or general. A strike-out with a note becomes replace with a suggested replacement; a caret with text becomes insert; a strike-out alone becomes delete.
  6. Score: exact (character range), line, region (figure, table, display maths) or page (needs a person). Each level carries a readable reason. Two near-equal matches are never exact.

Without SyncTeX

proofback searches the whole project for the marked text and its context, using page order as a hint. Confidence stays at line unless the match is unique and long: at least 20 folded characters, counting the marked text plus the PDF context on either side that agrees with the source right next to the match. A caret is placed after the longest unique text before it, or before the longest unique text after it, each at least 20 characters long; when both are found they must meet.

Older drafts

Each round records the git commit (when there is one) and hashes of the PDF and SyncTeX file it was imported against. For an older PDF, proofback import review.pdf --synctex old.synctex.gz --at <commit> anchors against that commit's files (read through git, never a shell), and sync carries the anchors forward to the working tree.

Anchors that survive edits

Each item stores a quote with prefix and suffix, a file position (byte range, line and column) and the PDF position (provenance only). sync tries the quote and its context first, then the position, and sets the item's anchor state to anchored, moved, changed or lost.

Files

All state is plain files in your project, meant to be committed:

.proofback/
  config.toml                  project root, main file, build directory, defaults
  rounds/
    2026-11-25-supervisor.json
    2027-01-10-reviewer-2.json
  cache/                       git-ignored; parsed SyncTeX and text indexes

Round files are written deterministically (items sorted by id, stable key order, two-space indent, trailing newline), so git diffs and merges stay readable. Their schema is v1.json; every round file names it in $schema.

{
  "id": "pb_7k2m9q",
  "round": "2026-11-25-supervisor",
  "kind": "replace",
  "author": "Prof. Hale",
  "created": "2026-11-24T18:03:00Z",
  "body": "Replace with \"robust\"",
  "suggestion": { "replace_with": "robust" },
  "target": {
    "file": "chapters/method.tex",
    "range": { "start": 1832, "end": 1838 },
    "line": 41, "column": 18,
    "quote": { "exact": "strong", "prefix": "The estimator is ", "suffix": " under" }
  },
  "anchor": { "state": "anchored", "confidence": "exact",
              "reason": "SyncTeX line 41 and a unique text match" },
  "origin": { "type": "pdf", "page": 14, "nm": "a7f3...", "quads": [[0, 0, 0, 0, 0, 0, 0, 0]],
              "pdf_sha256": "..." },
  "status": "open",
  "replies": [{ "author": "me", "body": "...", "at": "2026-11-26T09:12:00Z" }],
  "resolution": { "commit": null }
}
  • IDs are pb_ plus base32 characters of a hash of the round and the annotation's identity (/NM when present, otherwise page, type and quads), so importing the same PDF again never duplicates items. Unique prefixes are accepted.
  • Status is your decision: open, done, wontfix, discuss, duplicate. The anchor state is proofback's knowledge, kept separately.
  • Authors are stored as written in the PDF. --anonymize-authors on import replaces them with Reviewer 1, Reviewer 2 for blind review.

Outputs

Output Notes
Terminal list Grouped by file; colour only on a terminal
JSON Schema-validated, stable per schema version
Markdown GitHub task list, one line per item with a link to file and line
Unified diff Standard git apply format
Answered PDF A new file; the original is never modified; status and reply added as replies to each note
Response letter LaTeX or Markdown; quotes the reviewer, states the change, links the commit
SARIF 2.1.0 For code scanning annotations in pull requests
Review comments Through the GitHub Action

Performance

Budgets on a GitHub-hosted ubuntu-latest runner, for a 300-page thesis with 40 source files and 500 annotations. A test in CI (crates/proofback-corpus/tests/perf.rs) builds that input and fails when a budget is exceeded.

Operation Native Browser
import, cold cache under 1 s under 3 s
import, warm cache under 300 ms under 1 s
list under 50 ms not applicable
sync under 300 ms under 1 s
Peak memory under 300 MB under 400 MB
Browser app first load (before an import starts) not applicable under 150 KB compressed

PDF text is extracted only for annotated pages, pages are processed in one pass without threads (the same code runs in the browser), and indexes are cached by content hash in .proofback/cache/.

Accuracy

Measured by the tests in crates/proofback-corpus, run in CI on every pull request. The gates never get looser.

Corpus Items Exact Wrong Gate
LaTeX PDF annotations, with SyncTeX 256 97.8% (line 99.6%) 0.4% exact at least 90%, wrong under 1%
LaTeX PDF annotations, text only 256 98.7% (line 98.0%, page 2.0%) 0% exact at least 95.7%, wrong under 1%
Notes in an email 150 100 exact, 50 region 0 wrong under 1%
Word round trip 60 60 0 exact at least 90%
Typst 120 120 0 same as LaTeX
Handwritten marks, with SyncTeX 66 never exact by design (line 89.4%, page 10.6%) 0% wrong under 1%
Handwritten marks, text only 66 never exact by design (line 84.8%, page 15.2%) 0% wrong under 1%
Real-world PDFs 0 no data yet wrong under 1%; exact at least 90% from 100 items

"Wrong" counts any confident location that is not the right one. The corpus has 3 pdfLaTeX projects (article-twocolumn, thesis-basic, thesis-long with an \input tree) and 1 Typst project in fixtures/. A generator places every annotation type on known source ranges through SyncTeX forward search, the way Acrobat, Preview, Okular, Zotero and PDF Expert write them.

The generator only marks phrases that occur once in the project, so the text-only rows are an upper bound: a repeated phrase in a real review stays at line without SyncTeX. The real-world set in fixtures/real/ collects PDFs annotated in real applications and reports its numbers separately, per application.