Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 64 additions & 66 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,91 +5,89 @@ the JSON schema is versioned separately (`schema_version` in round files).

## Unreleased

### Accuracy

- Real-world set: `fixtures/real/` takes donated PDFs annotated in real applications,
each with a manifest and a ground-truth file. The accuracy test reports their
metrics per application and gates the wrong-anchor rate under 1%. It is empty for
now; `fixtures/real/README.md` explains how to donate.
- `cargo xtask real-check <dir>` checks a donation: manifest, PDF, truth file, and no
author names left in the metadata or the annotations.

### Website and app
### Breaking changes

- Command JSON (`--json` and MCP results) is now output schema 2, versioned apart
from round files: `schema_version` in command output is `2`, while round files on
disk stay at `1` and need no migration.
- Items in `import`, `list`, `show` and `resolve` JSON (and the MCP `list_items` and
`get_item` results) carry their location only in the `location` object; the flat
`file`, `line`, `column`, `end_line` and `page` fields are gone (#26). The VS Code
extension and the GitHub Action read both shapes.
- `doctor --json` prints one object with `tool`, `version`, `schema_version` and a
`checks` array instead of a bare array (#25).
- `doctor` exits `1` when a check fails (was `3`); `3` now means only that the
`--pdf` file could not be read (#25).

### New

- Shared design base with overfull: `tokens.shared.css` (status colours, focus ring,
monospace and document fonts), the same wordmark construction, and a footer line
that links the two tools.
- Status text uses the shared `--ok`, `--warn`, `--error` and `--info` colours; red
is kept for strike-outs and deletions.
- Commit Mono replaces JetBrains Mono. New favicon and social preview image with the
wordmark.

### Handwritten marks and skipped annotations

- `Ink` annotations (handwritten strokes from a tablet) become `comment` items that
point at the source lines they cover, or the line beside a margin mark. They are
never `exact`; a mark over more than 6 lines, or in the margin with no text beside
it, is `page`. Strokes on one page by one author that are closer than 12 pt merge
into one item. Without a note the body is `(handwritten mark)`. No handwriting
recognition and no model.
- `proofback locate` maps a position in the compiled PDF (page, rectangle, text) to
the file, line and columns of the source, with the same confidence rules as
`import`. One query from flags, or many as JSON Lines with `--stdin`. Stateless: no
`.proofback/` needed. Works without PDFium when each query has text. The same
`locate` is in the WebAssembly build and the Node package (with TypeScript types).
Schema: `site/schema/locate-v1.json`.
- Handwritten marks: `Ink` annotations become `comment` items that point at the source
lines they cover, or the line beside a margin mark. They are never `exact`; a mark
over more than 6 lines, or in the margin with no text beside it, is `page`. Strokes
on one page by one author closer than 12 pt merge into one item. Without a note the
body is `(handwritten mark)`. No handwriting recognition and no model.
- `import` prints one line per skipped annotation subtype (links, form fields and
other non-feedback annotations) with its count and pages, and `import --json` has a
`skipped` array (`subtype`, `page`, `count`). Nothing is dropped silently.
- `doctor --pdf <file>` lists the annotation subtypes in a review PDF and which ones
become items.
- README and the plan list what happens to each annotation subtype.
- Accuracy: a separate ink set in the corpus (3 forms of handwritten marks), wrong-anchor
rate 0% with and without SyncTeX.
- New fuzz target for the PDF annotation reader, including `/InkList`.
- Handoffs to overfull: `apply` and `sync` end with `Next: run "overfull check" before
you send the new draft.` when they changed an item and the project has
`overfull.yml` (hidden with `--json`, `--quiet` or `hints = false`).
`letter --diff-pdf <file>` names a PDF with the changes highlighted, for example
from `overfull diff`; the file must exist inside the project (exit code 3
otherwise). The agent kit uses `overfull cite`, `overfull check --json` and
`overfull diff` when overfull is installed.
- Interop v1 with overfull (`docs/interop.md`): one location object, shared exit
codes, SARIF conventions, and `tool`, `version`, `schema_version` on every `--json`
object. SARIF locations carry `uriBaseId: %SRCROOT%`.

### Handoffs to overfull

- `apply` and `sync` end with `Next: run "overfull check" before you send the new
draft.` when they changed at least one item and the project has `overfull.yml`.
Hidden with `--json`, `--quiet` or `hints = false` in `.proofback/config.toml`.
- `letter --diff-pdf <file>` names a PDF with the changes highlighted (for example
from `overfull diff`). The file must exist inside the project (exit code 3
otherwise).
- The agent kit tells agents to use `overfull cite`, `overfull check --json` and
`overfull diff` when overfull is installed, and to skip them otherwise.

### Accuracy without SyncTeX
### Accuracy

- Text-only mode finds the exact range for 98.7% of the corpus (was 43.3%), still
with 0% wrong anchors. A short unique match counts as long when the text around it
in the PDF agrees with the source; carets are placed by the longest unique text
next to them. The corpus test prints why each remaining item is not exact, and a
new gate keeps the text-only exact rate at 95.7% or more.
- The browser app shows a notice when an import starts without a SyncTeX file, with
the text-only rates and how to get the file (also from Overleaf). `proofback
doctor` prints the same advice.
new gate keeps the text-only exact rate at 95.7% or more. The corpus marks phrases
that occur once, so real reviews with repeated phrases will score lower.
- Without a SyncTeX file, the browser app shows a notice with the text-only rates and
how to get the file (also from Overleaf); `proofback doctor` prints the same advice.
- Ink set: 3 forms of handwritten marks, wrong-anchor rate 0% with and without SyncTeX.
- Real-world set: `fixtures/real/` takes donated PDFs annotated in real applications,
with a manifest and a ground-truth file each. The test reports metrics per
application and gates the wrong-anchor rate under 1%. It is empty for now;
`fixtures/real/README.md` explains how to donate, and `cargo xtask real-check <dir>`
checks a donation (including that no author names are left).

### Interop with overfull
### Security

- `docs/interop.md` (Interop v1) defines the location object, the exit codes, the SARIF
conventions and the top-level JSON fields that proofback and overfull share.
- Each item in `import`, `list`, `show` and `resolve` JSON has a `location` object
(`file`, `line`, `column`, `end_line`, `end_column`, `page`). The existing flat
fields stay.
- JSON objects from `import`, `list`, `show`, `resolve`, `sync` and `stats` carry
`tool`, `version` and `schema_version`.
- SARIF locations carry `uriBaseId: %SRCROOT%`.
- Annotation subtypes read from a PDF are escaped before they are printed, so a
crafted PDF cannot put newlines or instructions into output that agents read.
- The `overfull diff` tip of `letter` prints a round's commit only when it is a plain
hash or ref name.
- New fuzz targets: the PDF annotation reader (including `/InkList`) and the locator's
query parser.

### Locator
### Website and app

- `proofback locate` maps a position in the compiled PDF (page, rectangle, text) to
the file, line and columns of the source, with the same confidence rules as
`import`. One query from flags, or many as JSON Lines with `--stdin`. Stateless: no
`.proofback/` needed. Works without PDFium when each query has text.
- The same `locate` in the WebAssembly build and the Node package (with TypeScript
types). Schema: `site/schema/locate-v1.json`.
- Shared design base with overfull: `tokens.shared.css` (status colours, focus ring,
monospace and document fonts), the same wordmark construction, and a footer line
that links the two tools. Status text uses the shared `--ok`, `--warn`, `--error`
and `--info` colours; red is kept for strike-outs and deletions.
- Commit Mono replaces JetBrains Mono. New favicon and social preview image.

### Documentation

- README: one table of supported inputs (annotated PDF, email notes, Word, Typst) with the
accuracy mode of each.
- Plan: the corpus section states the actual corpus; a scope rule (no new product
surface before v1.0) and measurable v1.0 exit criteria.
- README: tables of supported inputs and of what happens to each PDF annotation
subtype; how to get the SyncTeX file without a local build and on Overleaf.
- Plan: the actual corpus, a scope rule (no new product surface before v1.0) and
measurable v1.0 exit criteria.

## 0.2.0 (2026-11-25)

Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ proofback import thesis-reviewed.docx # tracked changes and comments co
proofback import paper.pdf # Typst projects work the same way
```

Where does a place in the PDF come from? `proofback locate` answers without a review
round, for tools such as [overfull](https://github.com/Amet13/overfull) that know a page
and a position:

```bash
proofback locate --pdf main.pdf --synctex main.synctex.gz --page 3 --rect 72,640,300,652 --json
# {"file": "chapters/method.tex", "line": 41, "column": 18, "end_line": 41, "end_column": 24,
# "confidence": "exact", "reason": "..."}
```

Many queries go as JSON Lines on `--stdin`; the Node package has the same `locate`.

Agents: `proofback mcp` runs an MCP server on stdio; see [`docs/agents.md`](docs/agents.md)
and the agent kit in [`integrations/`](integrations/). Pull requests: see
[`docs/github-action.md`](docs/github-action.md). VS Code: [`integrations/vscode`](integrations/vscode).
Expand All @@ -137,6 +149,7 @@ Measured in CI on every pull request (details in [`docs/PLAN.md`](docs/PLAN.md#2
| Annotated PDF, text only | 98.7% (98.0% correct line) | 0% |
| Word round trip | 100% | 0% |
| Typst | 100% | 0% |
| Handwritten marks (ink) | never exact by design; right line 89.4% | 0% |
| Real-world PDFs (0 items) | no data yet | no data yet |

The synthetic corpus has 256 annotations on 3 pdfLaTeX projects and 1 Typst project.
Expand Down
23 changes: 16 additions & 7 deletions crates/proofback-cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,14 @@ fn cmd_import(p: &Project, a: &ImportArgs, quiet: bool, style: &Style) -> Result
}

/// `doctor --pdf`: the annotation subtypes in a review PDF, imported and skipped.
fn annotation_checks(pdf: &Path, checks: &mut Vec<(&str, &str, String)>) {
/// Returns false when the PDF could not be read.
fn annotation_checks(pdf: &Path, checks: &mut Vec<(&str, &str, String)>) -> bool {
let limits = proofback_store::LimitsConfig::default();
match crate::extract::extract_isolated(pdf, &limits) {
Err(e) => checks.push(("fail", "annotations", e.to_string())),
Err(e) => {
checks.push(("fail", "annotations", e.to_string()));
false
}
Ok(x) => {
let mut imported: BTreeMap<&str, usize> = BTreeMap::new();
for a in &x.annotations {
Expand Down Expand Up @@ -415,6 +419,7 @@ fn annotation_checks(pdf: &Path, checks: &mut Vec<(&str, &str, String)>) {
if !skipped.is_empty() {
checks.push(("ok", "annotations", format!("skipped: {}", list(&skipped))));
}
true
}
}
}
Expand Down Expand Up @@ -976,9 +981,9 @@ fn cmd_stats(p: &Project, json: bool) -> Result<u8> {

fn cmd_doctor(start: &Path, json: bool, review: Option<&Path>, style: &Style) -> u8 {
let mut checks: Vec<(&str, &str, String)> = Vec::new();
if let Some(pdf) = review {
annotation_checks(pdf, &mut checks);
}
// Exit code 3 is for input doctor cannot read (the --pdf file); a failed check
// of the setup is "needs action", exit code 1 (#25, Interop v1 §3).
let unreadable = review.is_some_and(|pdf| !annotation_checks(pdf, &mut checks));
let project = Project::discover(start);
match &project {
Ok(p) => {
Expand Down Expand Up @@ -1057,7 +1062,7 @@ fn cmd_doctor(start: &Path, json: bool, review: Option<&Path>, style: &Style) ->
.iter()
.map(|(s, n, d)| serde_json::json!({"status": s, "check": n, "detail": d}))
.collect();
println!("{}", serde_json::to_string_pretty(&v).expect("json"));
crate::output::print_json(&serde_json::json!({ "checks": v }));
} else {
for (s, n, d) in &checks {
let tag = match *s {
Expand All @@ -1068,7 +1073,11 @@ fn cmd_doctor(start: &Path, json: bool, review: Option<&Path>, style: &Style) ->
println!("[{tag}] {n}: {d}");
}
}
if failed { 3 } else { 0 }
match (unreadable, failed) {
(true, _) => 3,
(false, true) => 1,
(false, false) => 0,
}
}

#[cfg(test)]
Expand Down
4 changes: 2 additions & 2 deletions crates/proofback-cli/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::io::IsTerminal;

use proofback_model::{Confidence, Item, Origin, SCHEMA_VERSION, Status};
use proofback_model::{Confidence, Item, OUTPUT_SCHEMA_VERSION, Origin, Status};

/// Add the top-level fields every `--json` object carries (Interop v1, `docs/interop.md`):
/// `tool`, `version` and `schema_version`. Existing fields are kept as they are.
Expand All @@ -11,7 +11,7 @@ pub fn envelope(value: serde_json::Value) -> serde_json::Value {
serde_json::Value::Object(mut map) => {
map.insert("tool".into(), "proofback".into());
map.insert("version".into(), env!("CARGO_PKG_VERSION").into());
map.insert("schema_version".into(), SCHEMA_VERSION.into());
map.insert("schema_version".into(), OUTPUT_SCHEMA_VERSION.into());
serde_json::Value::Object(map)
}
other => other,
Expand Down
49 changes: 39 additions & 10 deletions crates/proofback-cli/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ fn full_review_round() {
assert!(out.contains("\"r1\""), "{out}");

let (code, out, err) = run(d, &["doctor"]);
assert!(code == 0 || code == 3, "{err}");
assert!(code == 0 || code == 1, "{err}");
assert!(out.contains("project"), "{out}");

// Re-import keeps decisions.
Expand Down Expand Up @@ -275,11 +275,11 @@ fn notes_import_locates_quotes_sections_and_pages() {
};
let sec = by_text("Section 3.1");
assert_eq!(sec["confidence"], "region");
assert_eq!(sec["file"], "chapters/ch3-method.tex");
assert_eq!(sec["location"]["file"], "chapters/ch3-method.tex");
let para = by_text("p. 5");
assert_eq!(para["confidence"], "line", "{para}");
let ch = by_text("Chapter 2");
assert_eq!(ch["file"], "chapters/ch2-background.tex");
assert_eq!(ch["location"]["file"], "chapters/ch2-background.tex");
}

#[test]
Expand Down Expand Up @@ -520,7 +520,7 @@ fn check_location(loc: &serde_json::Value, confidence: &str, origin_has_page: bo
fn check_envelope(v: &serde_json::Value) {
assert_eq!(v["tool"], "proofback", "{v}");
assert_eq!(v["version"], env!("CARGO_PKG_VERSION"), "{v}");
assert_eq!(v["schema_version"], 1, "{v}");
assert_eq!(v["schema_version"], 2, "{v}");
}

#[test]
Expand Down Expand Up @@ -554,11 +554,9 @@ fn interop_v1_location_and_envelope() {
for it in items {
let loc = &it["location"];
check_location(loc, it["confidence"].as_str().unwrap(), true);
// The flat schema v1 fields agree with the location object.
for k in ["file", "line", "column", "end_line", "page"] {
if it["confidence"] != "page" || k == "page" {
assert_eq!(it.get(k), loc.get(k), "{k} in {it}");
}
// Output schema 2: the location object is the only place for these (#26).
for k in ["file", "line", "column", "end_line", "end_column", "page"] {
assert!(it.get(k).is_none(), "flat {k} in {it}");
}
}

Expand Down Expand Up @@ -945,7 +943,10 @@ fn every_subtype_is_imported_or_reported() {
"{ink}"
);
let ink_id = ink["id"].as_str().unwrap();
assert!(rows.iter().any(|r| r["id"] == ink_id && r["page"] == 3));
assert!(
rows.iter()
.any(|r| r["id"] == ink_id && r["location"]["page"] == 3)
);

// Human output names the skipped subtypes with counts.
let (_, out, _) = run(d, &["import", "subtypes.pdf", "--round", "s2"]);
Expand Down Expand Up @@ -1007,3 +1008,31 @@ fn subtype_table_matches_readme() {
}
}
}

/// `doctor --json` (output schema 2, #25): one object with the Interop v1 fields and
/// a `checks` array; exit code 1 when a check fails, 3 when its input is unreadable.
#[test]
fn doctor_json_and_exit_codes() {
let dir = tempfile::tempdir().unwrap();
let d = dir.path();
// No project at all: the project check fails, which needs action (1).
let (code, out, err) = run(d, &["doctor", "--json"]);
assert_eq!(code, 1, "{err}");
let v: serde_json::Value = serde_json::from_str(&out).unwrap();
assert_eq!(v["tool"], "proofback");
assert_eq!(v["schema_version"], 2);
let checks = v["checks"].as_array().unwrap();
assert!(
checks
.iter()
.any(|c| c["check"] == "project" && c["status"] == "fail"),
"{v}"
);
for c in checks {
assert!(c["status"].is_string() && c["check"].is_string() && c["detail"].is_string());
}
// A --pdf that cannot be read is unreadable input (3).
std::fs::write(d.join("broken.pdf"), b"not a pdf").unwrap();
let (code, _, err) = run(d, &["doctor", "--pdf", "broken.pdf"]);
assert_eq!(code, 3, "{err}");
}
5 changes: 5 additions & 0 deletions crates/proofback-model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ pub use id::{ItemId, PrefixError, resolve_prefix};

/// Version of the round-file schema. Bumped only for breaking changes.
pub const SCHEMA_VERSION: u32 = 1;
/// Version of the JSON that commands print (`--json`, MCP results): the
/// `schema_version` of Interop v1. Separate from [`SCHEMA_VERSION`] so that a change
/// to command output never makes stored round files unreadable. 2 since the flat
/// location fields left item rows and `doctor --json` became an object (#25, #26).
pub const OUTPUT_SCHEMA_VERSION: u32 = 2;
/// Public location of the JSON Schema for [`RoundFile`].
pub const SCHEMA_URL: &str = "https://amet13.github.io/proofback/schema/v1.json";

Expand Down
Loading
Loading