Repository navigation
Locator API: map a PDF position to a source range - #33
Merged
Merged
Conversation
proofback_anchor::locate runs the import pipeline for stateless queries (page, rect, text) and returns file, line, columns, confidence and reason. Exposed as proofback locate (flags or JSON Lines on --stdin), in the WebAssembly build and the Node package with TypeScript types. Schema in site/schema/locate-v1.json (cargo xtask schema). PDF parsing stays in the isolated child; queries are bounded; no .proofback/ is read or written. Tests: the corpus asks every synthetic markup annotation as a query and gets the import's range and confidence; Node matches native on 90 sample queries; the perf test times 500 queries; a fuzz target covers the parser. Refs #19 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xj9ekYmyESdZUsW8uWkzgv
…jan-4sc5w7-locator # Conflicts: # CHANGELOG.md
Amet13
marked this pull request as ready for review
December 1, 2026 01:00
…jan-4sc5w7-locator # Conflicts: # CHANGELOG.md # docs/PLAN.md
Amet13
pushed a commit
that referenced
this pull request
Dec 1, 2026
The real-world gate test moves from accuracy.rs to tests/real.rs, the CHANGELOG section sits at its own place, and the website row gets its own table body, so this PR and #31, #32 and #33 merge in any order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xj9ekYmyESdZUsW8uWkzgv
Amet13
pushed a commit
that referenced
this pull request
Dec 1, 2026
The ink accuracy set moves from accuracy.rs to tests/ink.rs, the CHANGELOG section sits at its own place, and the nightly fuzz workflow now runs every [[bin]] of fuzz/Cargo.toml (so no target needs a workflow edit). This PR and #30, #32 and #33 then merge in any order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xj9ekYmyESdZUsW8uWkzgv
The nightly fuzz workflow on main runs every [[bin]] of fuzz/Cargo.toml, so locate_query needs no workflow edit. extract_pages fills the new Extracted.skipped field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xj9ekYmyESdZUsW8uWkzgv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #19.
Query and result
proofback_model::locate::Query):page(1-based, required),rect[x0, y0, x1, y1](PDF points, origin bottom-left),text. At least one ofrectand a non-emptytextis required.Query::validateenforces this plus bounds: finite coordinates, x0 ≤ x1 and y0 ≤ y1, text up to 4,096 characters.Location):file,line,column,end_line,end_columnwith the units ofTarget, plusconfidenceandreasonwith the values ofAnchor. Apageresult has no source fields.Surfaces
pub fn locate(input: &Input<'_>, queries: &[Query]) -> Vec<Location>inproofback-anchor.anchor_oneis split so that the locator and the import share its core (anchor_marked); nothing is copied. With PDFium page text, a query'stextis found on the page (the occurrence nearestrect) and read with the same PDF context the import uses. Without page text, the query text is aligned on its own.locate(pdf, synctex?, sources_json, queries_json).require('proofback').locate(pdf, { synctex, sources, queries }), withLocateQueryandLocateResultTypeScript types. Documented innpm/README.md.proofback locate --pdf <file> [--synctex <file>] --page <n> [--rect x0,y0,x1,y1] [--text <s>] [--json]. With--stdin, one JSON query per line and one JSON result per line. Documented in PLAN §7.Behaviour
--projector the current directory with a default configuration; it never opens.proofback/. A test checks that no.proofback/appears.textwork. The isolated parser child has a newpages=mode that returns page boxes (lopdf) and, when PDFium is present, the text of the queried pages.2for a malformed command line;3for an unreadable PDF or SyncTeX file, or an invalid or unparseable query line (the message names the line).Schema and docs
site/schema/locate-v1.jsonis generated from the types bycargo xtask schema, and--checkcovers it as it coversv1.json. The locator is documented in PLAN §7,npm/README.md,site/llms.txtand the CHANGELOG.Acceptance
proofback-corpus/tests/locate.rsasks every synthetic markup annotation (highlight, strike-out, underline, squiggly; 300+ per mode) as a locator query, with page, rect and the text the import read. Range (file, line, columns) and confidence equal the import's, with and without SyncTeX. Carets and sticky notes are excluded: they ask "where to insert" or "which line is this note beside", not "where does this text come from", so they have no locator query.cargo xtask samplenow also writes 90 locator queries (rect + text, text only, rect only) and their native results.npm/testruns them through the Node (WebAssembly) build and requires deep equality; it passes locally. The CIpages.ymljob already runsxtask samplebeforenpm test.tests/perf.rsnow times 500 cold queries on the reference input (page text, SyncTeX and sources parsed from scratch) against the 1 s cold import budget. Not run locally: that test needs the 300-page fixture built with pdflatex, which this container lacks. CI'sperfjob runs it on this PR.locate_queryforparse_queries(added tofuzz.yml), asserting every accepted query passes validation and the bounds.Tests
PROOFBACK_REQUIRE_PDFIUM=1 cargo test --workspacepasses, includingcli/tests/locate.rs:--json;--stdinwith text-only, not-found and out-of-range queries;.proofback/created.npm testpasses (import and locator parity). Clippy is clean apart from warnings that already exist onmain.cargo checkpasses for the fuzz crate.Notes
proofback_pdf::extract_pagesandTextChar::center.Generated by Claude Code