From f21ec3f50dd90f83ca0f66b3426d7e538dc839c6 Mon Sep 17 00:00:00 2001
From: Claude
Date: Wed, 2 Dec 2026 00:15:44 +0000
Subject: [PATCH 1/2] Prepare v1.0.0: stability promise, faster matching,
public reference docs
- docs/stability.md: the 1.x semver contract; a test pins both published
JSON schemas.
- SECURITY.md: threat model and supported versions.
- docs/reference.md replaces the internal plan (docs/PLAN.md, its audit
and decision logs are removed); every reference updated.
- SyncTeX node records parsed as bytes (differential test against the
str-based parser); aligner stops each column at Ukkonen's cut-off
(differential test against the full table); ASCII fast path in folding.
Accuracy unchanged; Rust side of a cold import ~115 ms -> ~85 ms on the
322-page reference thesis.
- Cleanup: unused parameters, shared PDFium loader in corpus tests.
- Version 1.0.0.
Co-Authored-By: Claude Opus 5.5
Claude-Session: https://claude.ai/code/session_01Xj9ekYmyESdZUsW8uWkzgv
---
AGENTS.md | 4 +-
CHANGELOG.md | 40 +
Cargo.lock | 33 +-
Cargo.toml | 2 +-
README.md | 8 +-
SECURITY.md | 27 +-
crates/proofback-anchor/Cargo.toml | 8 +-
crates/proofback-anchor/src/align.rs | 154 +++-
crates/proofback-anchor/src/classify.rs | 2 +-
crates/proofback-anchor/src/ink.rs | 2 +-
crates/proofback-anchor/src/lib.rs | 11 +-
crates/proofback-anchor/src/locate.rs | 2 +-
crates/proofback-cli/Cargo.toml | 22 +-
crates/proofback-cli/src/commands.rs | 2 +-
crates/proofback-cli/src/extract.rs | 2 +-
crates/proofback-cli/src/output.rs | 2 +-
crates/proofback-cli/tests/e2e.rs | 13 +-
crates/proofback-corpus/Cargo.toml | 10 +-
crates/proofback-corpus/src/lib.rs | 15 +-
crates/proofback-corpus/src/real.rs | 4 +-
crates/proofback-corpus/tests/accuracy.rs | 17 +-
crates/proofback-corpus/tests/ink.rs | 15 +-
crates/proofback-corpus/tests/locate.rs | 15 +-
.../proofback-corpus/tests/notes_accuracy.rs | 2 +-
crates/proofback-corpus/tests/real.rs | 25 +-
crates/proofback-docx/Cargo.toml | 6 +-
crates/proofback-docx/src/import.rs | 2 -
crates/proofback-docx/src/tests.rs | 2 +-
crates/proofback-emit/Cargo.toml | 4 +-
crates/proofback-mcp/Cargo.toml | 8 +-
.../proofback-model/tests/frozen_schemas.rs | 37 +
crates/proofback-notes/Cargo.toml | 8 +-
crates/proofback-store/Cargo.toml | 4 +-
crates/proofback-store/src/config.rs | 2 +-
crates/proofback-store/src/views.rs | 2 +-
crates/proofback-synctex/Cargo.toml | 1 +
crates/proofback-synctex/src/lib.rs | 283 ++++--
crates/proofback-tex/src/fold.rs | 42 +
crates/proofback-typst/Cargo.toml | 8 +-
crates/proofback-typst/tests/corpus.rs | 2 +-
crates/proofback-wasm/Cargo.toml | 12 +-
docs/PLAN.md | 850 ------------------
docs/agents.md | 2 +-
docs/github-action.md | 4 +-
docs/reference.md | 272 ++++++
docs/stability.md | 41 +
fixtures/real/README.md | 2 +-
.../claude-code/.claude-plugin/plugin.json | 2 +-
integrations/vscode/package-lock.json | 4 +-
integrations/vscode/package.json | 2 +-
npm/package.json | 2 +-
site/llms.txt | 5 +-
xtask/Cargo.toml | 8 +-
53 files changed, 961 insertions(+), 1093 deletions(-)
create mode 100644 crates/proofback-model/tests/frozen_schemas.rs
delete mode 100644 docs/PLAN.md
create mode 100644 docs/reference.md
create mode 100644 docs/stability.md
diff --git a/AGENTS.md b/AGENTS.md
index 5884e38..809d0d3 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -10,7 +10,9 @@ LaTeX project, see `docs/agents.md`.)
- `fixtures/` LaTeX projects with built PDFs and SyncTeX files (`fixtures/generate.py`,
`cargo xtask fixtures`).
- `site/` static website; `tools/` checks for it.
-- `docs/PLAN.md` the plan and decision log. Keep it in sync with behaviour changes.
+- `docs/reference.md` commands, matching, files, performance and accuracy;
+ `docs/stability.md` the 1.x interface promise. Keep both in sync with behaviour
+ changes.
## Commands
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5537ecf..c8b5e29 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,46 @@ the JSON schema is versioned separately (`schema_version` in round files).
## Unreleased
+## 1.0.0 (2026-12-02)
+
+### Stable from 1.0
+
+- proofback follows Semantic Versioning for the interfaces listed in
+ `docs/stability.md`: the command line and exit codes, command JSON (output schema
+ 2), round files (schema 1, frozen for all of 1.x), the locator, the Node package,
+ the MCP tools, Interop v1, the release files and `.proofback/config.toml`. A test
+ pins both published JSON schemas.
+- `SECURITY.md` now holds the threat model and says which versions get security
+ fixes: the latest 1.x release.
+- The real-world accuracy set (`fixtures/real/`) is still empty; accuracy figures
+ come from the synthetic corpus and are labelled that way. A Homebrew tap is not
+ planned for now: install with `install.sh`, `install.ps1` or a release archive.
+
+### Faster
+
+- SyncTeX files are parsed about 15% faster: node records are read as bytes instead
+ of through UTF-8 strings.
+- Matching a marked phrase is 2 to 5 times faster on real text: the aligner stops
+ each column once no cheaper match is possible. Results are identical; a test
+ compares the new aligner with the old one on random input.
+- Normalising sources is about twice as fast for ASCII text.
+- On the 322-page reference thesis, the Rust side of a cold import (SyncTeX,
+ sources and matching) takes about 85 ms instead of 115 ms; the rest is PDFium.
+
+### Documentation
+
+- `docs/reference.md` replaces the internal plan: commands, exit codes, what
+ `import` does with each annotation type, how a mark finds its source, the files in
+ `.proofback/`, performance budgets and accuracy. The plan, its audit log and its
+ decision log are gone.
+- `site/llms.txt` links the reference and the stability page, and its changelog link
+ points at `main`.
+
+### Cleanup
+
+- Removed unused parameters and variables in the matcher and the DOCX importer, and
+ shared one PDFium loader between the corpus tests.
+
### Interop with overfull 4.0
- `docs/interop.md` records overfull 4.0's exit code `70` for internal errors
diff --git a/Cargo.lock b/Cargo.lock
index 4a7c293..c8a46d0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2753,7 +2753,7 @@ dependencies = [
[[package]]
name = "proofback-ai"
-version = "0.3.0"
+version = "1.0.0"
dependencies = [
"base64 0.23.1",
"serde",
@@ -2764,7 +2764,7 @@ dependencies = [
[[package]]
name = "proofback-anchor"
-version = "0.3.0"
+version = "1.0.0"
dependencies = [
"proofback-model",
"proofback-pdf",
@@ -2774,7 +2774,7 @@ dependencies = [
[[package]]
name = "proofback-cli"
-version = "0.3.0"
+version = "1.0.0"
dependencies = [
"clap",
"lopdf",
@@ -2799,7 +2799,7 @@ dependencies = [
[[package]]
name = "proofback-corpus"
-version = "0.3.0"
+version = "1.0.0"
dependencies = [
"lopdf",
"pdfium-render",
@@ -2818,7 +2818,7 @@ dependencies = [
[[package]]
name = "proofback-docx"
-version = "0.3.0"
+version = "1.0.0"
dependencies = [
"proofback-anchor",
"proofback-model",
@@ -2830,7 +2830,7 @@ dependencies = [
[[package]]
name = "proofback-emit"
-version = "0.3.0"
+version = "1.0.0"
dependencies = [
"proofback-model",
"proofback-pdf",
@@ -2839,7 +2839,7 @@ dependencies = [
[[package]]
name = "proofback-mcp"
-version = "0.3.0"
+version = "1.0.0"
dependencies = [
"proofback-anchor",
"proofback-emit",
@@ -2851,7 +2851,7 @@ dependencies = [
[[package]]
name = "proofback-model"
-version = "0.3.0"
+version = "1.0.0"
dependencies = [
"schemars",
"serde",
@@ -2862,7 +2862,7 @@ dependencies = [
[[package]]
name = "proofback-notes"
-version = "0.3.0"
+version = "1.0.0"
dependencies = [
"proofback-anchor",
"proofback-model",
@@ -2875,7 +2875,7 @@ dependencies = [
[[package]]
name = "proofback-pdf"
-version = "0.3.0"
+version = "1.0.0"
dependencies = [
"lopdf",
"pdfium-render",
@@ -2885,7 +2885,7 @@ dependencies = [
[[package]]
name = "proofback-store"
-version = "0.3.0"
+version = "1.0.0"
dependencies = [
"proofback-anchor",
"proofback-model",
@@ -2899,15 +2899,16 @@ dependencies = [
[[package]]
name = "proofback-synctex"
-version = "0.3.0"
+version = "1.0.0"
dependencies = [
"flate2",
+ "memchr",
"thiserror 2.0.21",
]
[[package]]
name = "proofback-tex"
-version = "0.3.0"
+version = "1.0.0"
dependencies = [
"proptest",
"unicode-normalization",
@@ -2915,7 +2916,7 @@ dependencies = [
[[package]]
name = "proofback-typst"
-version = "0.3.0"
+version = "1.0.0"
dependencies = [
"proofback-anchor",
"proofback-model",
@@ -2929,7 +2930,7 @@ dependencies = [
[[package]]
name = "proofback-wasm"
-version = "0.3.0"
+version = "1.0.0"
dependencies = [
"pdfium-render",
"proofback-anchor",
@@ -5406,7 +5407,7 @@ checksum = "9440ea3e5aeabb0ac63af70daf835274065238cdd0cec83418f417eae38bacee"
[[package]]
name = "xtask"
-version = "0.3.0"
+version = "1.0.0"
dependencies = [
"anyhow",
"proofback-anchor",
diff --git a/Cargo.toml b/Cargo.toml
index 10245a2..6f87afc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,7 +5,7 @@ exclude = ["fuzz"]
default-members = ["crates/*"]
[workspace.package]
-version = "0.3.0"
+version = "1.0.0"
edition = "2024"
rust-version = "1.92"
license = "MIT OR Apache-2.0"
diff --git a/README.md b/README.md
index d5846c7..766ee7f 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
Website ·
Browser app ·
Changelog ·
- Design notes ·
+ Reference ·
For agents
@@ -180,7 +180,7 @@ Many queries go as JSON Lines on `--stdin`; the Node package has the same `locat
## Accuracy
-Measured in CI on every pull request (details in [`docs/PLAN.md`](docs/PLAN.md#21-implementation-notes)):
+Measured in CI on every pull request on generated test annotations; no real-world PDFs have been donated yet (details in [`docs/reference.md`](docs/reference.md#accuracy)):
| Input | Exact range | Wrong anchor |
|---|---|---|
@@ -237,7 +237,9 @@ PROOFBACK_REQUIRE_PDFIUM=1 cargo test --workspace # tests and accuracy gates
cd tools && npm ci && npx playwright install chromium && npm run check # website
```
-Rules for changes (accuracy gates, untrusted input, no telemetry) are in
+What 1.0 keeps stable (commands, exit codes, JSON, schemas, Node API, MCP tools) is in
+[`docs/stability.md`](docs/stability.md). Rules for changes (accuracy gates, untrusted
+input, no telemetry) are in
[`AGENTS.md`](AGENTS.md); releases are automatic ([`docs/releasing.md`](docs/releasing.md)).
Security reports: [`SECURITY.md`](SECURITY.md).
diff --git a/SECURITY.md b/SECURITY.md
index a41c38e..fa954da 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -17,9 +17,30 @@ relevant), and the impact you expect. You should get a first reply within 7 days
- The `proofback` CLI, MCP server, GitHub Action, browser app and npm package.
- The website at .
-The threat model and the mitigations proofback commits to are in
-[`docs/PLAN.md` §10](docs/PLAN.md#10-security-and-privacy-d-16).
+## Threat model
+
+proofback reads files written by other people (PDFs, DOCX, notes) and can write to
+your source. These are the threats it is built against and the mitigations it commits
+to. There is no telemetry anywhere in the project.
+
+| Threat | Mitigation |
+|---|---|
+| Malicious PDF exploiting the PDF parser | pdfium is fuzzed upstream and pinned to a recent Chromium branch; proofback updates it on every Chromium security release. In the browser it runs inside the WebAssembly sandbox. Native imports parse the PDF in a child process with memory and time limits. proofback's own parsers are fuzzed with `cargo-fuzz` in CI. |
+| Decompression bombs (`.synctex.gz`, DOCX zip, PDF streams) | Hard limits on decompressed size, entry count, page count and annotation count, all configurable. |
+| XML attacks in DOCX | `quick-xml` with no DTD or external entity resolution. |
+| Path traversal (SyncTeX paths, `\input`, zip entries, `--at` checkouts) | Every path is canonicalised and must stay inside the project root; symlinks leaving the root are refused. |
+| Unwanted writes | Only `apply`, `inline` and `resolve` write. `apply` checks the anchored text is unchanged and never writes outside the root. `--dry-run` everywhere. |
+| Prompt injection through reviewer comments | Reviewer text is marked untrusted in JSON and MCP output; the agent kit tells agents to treat it as data; proofback exposes no tool that runs commands. |
+| Leaking source to an AI provider | `suggest` is off by default, needs per-project consent, shows the payload, and reads API keys from an environment variable named in the config, never from committed files. |
+| Reviewer identity in blind review | `--anonymize-authors` on import; `answer` and `letter` strip PDF metadata (author, creator tool, local paths). |
+| GitHub Action abuse | Runs on `pull_request` with a read-only token by default; posting comments uses a separate `workflow_run` job; all third-party actions pinned by commit SHA; least-privilege `permissions`. |
+| Supply chain | `cargo-deny` (licences, advisories, sources) in CI, Dependabot, release artefacts with SHA-256 checksums and signed build provenance (GitHub attestations), npm provenance, pinned pdfium binaries with checksums. |
+| Website | No third-party requests (fonts self-hosted), Content Security Policy, no cookies or analytics. |
## Supported versions
-Before 1.0, only the latest release receives security fixes.
+| Version | Security fixes |
+|---|---|
+| Latest 1.x release | Yes |
+| Older 1.x releases | No: update to the latest 1.x, which keeps every interface in [`docs/stability.md`](docs/stability.md) |
+| 0.x | No |
diff --git a/crates/proofback-anchor/Cargo.toml b/crates/proofback-anchor/Cargo.toml
index 0ea1e7a..6c4f639 100644
--- a/crates/proofback-anchor/Cargo.toml
+++ b/crates/proofback-anchor/Cargo.toml
@@ -9,10 +9,10 @@ homepage.workspace = true
publish.workspace = true
[dependencies]
-proofback-model = { version = "0.3.0", path = "../proofback-model" }
-proofback-pdf = { version = "0.3.0", path = "../proofback-pdf" }
-proofback-synctex = { version = "0.3.0", path = "../proofback-synctex" }
-proofback-tex = { version = "0.3.0", path = "../proofback-tex" }
+proofback-model = { version = "1.0.0", path = "../proofback-model" }
+proofback-pdf = { version = "1.0.0", path = "../proofback-pdf" }
+proofback-synctex = { version = "1.0.0", path = "../proofback-synctex" }
+proofback-tex = { version = "1.0.0", path = "../proofback-tex" }
[lints]
workspace = true
diff --git a/crates/proofback-anchor/src/align.rs b/crates/proofback-anchor/src/align.rs
index f44a94e..83dc6d8 100644
--- a/crates/proofback-anchor/src/align.rs
+++ b/crates/proofback-anchor/src/align.rs
@@ -28,7 +28,11 @@ pub struct Alignment {
/// Align `query` (folded characters) against `text` (folded characters).
///
/// Returns hits whose cost is at most `max_cost`. Complexity is
-/// `O(query.len() * text.len())`; callers keep the text to a window.
+/// `O(query.len() * text.len())` in the worst case; callers keep the text to a
+/// window. Every step costs 0 or 1, so a cell above `max_cost` can never lead to a
+/// reported hit: each column stops below the last row that can still be within
+/// budget (Ukkonen's cut-off), which usually makes the work closer to
+/// `O(max_cost * text.len())`.
pub fn align(query: &[char], text: &[char], max_cost: usize) -> Alignment {
let m = query.len();
let n = text.len();
@@ -37,28 +41,31 @@ pub fn align(query: &[char], text: &[char], max_cost: usize) -> Alignment {
}
// dp[j][i]: minimal cost of aligning query[..i] so that it ends at text[..j].
// start[j][i]: text index where that alignment starts.
- // Rolling columns over j.
+ // Rolling columns over j. Rows above a column's `top` hold `inf`: their true
+ // cost exceeds `max_cost`, and any such value behaves the same from here on.
let inf = usize::MAX / 4;
let mut prev = vec![inf; m + 1];
let mut prev_start = vec![0usize; m + 1];
let mut cur = vec![inf; m + 1];
let mut cur_start = vec![0usize; m + 1];
- prev[0] = 0;
- prev_start[0] = 0;
// Column 0 (empty text prefix): deleting query characters.
- for i in 1..=m {
- prev[i] = i;
- prev_start[i] = 0;
+ let mut prev_top = m.min(max_cost);
+ for (i, v) in prev.iter_mut().enumerate().take(prev_top + 1) {
+ *v = i;
}
+ let mut cur_top = 0;
let mut ends: Vec = Vec::new();
for j in 1..=n {
let t = text[j - 1];
cur[0] = 0;
cur_start[0] = j; // free leading text
+ // Rows up to `prev_top + 1` can use cells of the previous column that are
+ // within budget.
+ let bound = m.min(prev_top + 1);
if t == PLACEHOLDER {
// A placeholder absorbs a run of non-space query characters (the rendered
// reference), or nothing when it was not marked; both cost 0.
- for i in 1..=m {
+ for i in 1..=bound {
let (mut best, mut bs) = (prev[i], prev_start[i]);
if query[i - 1] != ' ' {
if prev[i - 1] < best {
@@ -74,7 +81,7 @@ pub fn align(query: &[char], text: &[char], max_cost: usize) -> Alignment {
cur_start[i] = bs;
}
} else {
- for i in 1..=m {
+ for i in 1..=bound {
let sub = prev[i - 1] + usize::from(query[i - 1] != t);
let del_text = prev[i] + 1; // extra text char
let del_query = cur[i - 1] + 1; // missing text char
@@ -91,15 +98,42 @@ pub fn align(query: &[char], text: &[char], max_cost: usize) -> Alignment {
cur_start[i] = bs;
}
}
- if cur[m] <= max_cost {
+ // Below that, both cells of the previous column are over budget, so only the
+ // cell above can keep this one within it: carry on while it does.
+ let mut top = bound;
+ while top < m && cur[top] <= max_cost {
+ let i = top + 1;
+ if t == PLACEHOLDER {
+ if query[i - 1] == ' ' {
+ break;
+ }
+ cur[i] = cur[i - 1];
+ } else {
+ cur[i] = cur[i - 1] + 1;
+ }
+ cur_start[i] = cur_start[i - 1];
+ top = i;
+ }
+ // Keep only rows within budget, and restore the invariant above them; this
+ // also clears rows left over from an older column.
+ let last = top;
+ while top > 0 && cur[top] > max_cost {
+ top -= 1;
+ }
+ for v in cur.iter_mut().take(last.max(cur_top) + 1).skip(top + 1) {
+ *v = inf;
+ }
+ if top == m {
ends.push(Hit {
start: cur_start[m],
end: j,
cost: cur[m],
});
}
+ cur_top = top;
std::mem::swap(&mut prev, &mut cur);
std::mem::swap(&mut prev_start, &mut cur_start);
+ std::mem::swap(&mut prev_top, &mut cur_top);
}
summarize(ends)
}
@@ -178,4 +212,104 @@ mod tests {
format!("in table {PLACEHOLDER} and")
);
}
+
+ /// The full-table version `align` replaced, kept to check the cut-off.
+ fn reference_align(query: &[char], text: &[char], max_cost: usize) -> Alignment {
+ let m = query.len();
+ let n = text.len();
+ if m == 0 || n == 0 {
+ return Alignment::default();
+ }
+ // dp[j][i]: minimal cost of aligning query[..i] so that it ends at text[..j].
+ // start[j][i]: text index where that alignment starts.
+ // Rolling columns over j.
+ let inf = usize::MAX / 4;
+ let mut prev = vec![inf; m + 1];
+ let mut prev_start = vec![0usize; m + 1];
+ let mut cur = vec![inf; m + 1];
+ let mut cur_start = vec![0usize; m + 1];
+ prev[0] = 0;
+ prev_start[0] = 0;
+ // Column 0 (empty text prefix): deleting query characters.
+ for i in 1..=m {
+ prev[i] = i;
+ prev_start[i] = 0;
+ }
+ let mut ends: Vec = Vec::new();
+ for j in 1..=n {
+ let t = text[j - 1];
+ cur[0] = 0;
+ cur_start[0] = j; // free leading text
+ if t == PLACEHOLDER {
+ // A placeholder absorbs a run of non-space query characters (the rendered
+ // reference), or nothing when it was not marked; both cost 0.
+ for i in 1..=m {
+ let (mut best, mut bs) = (prev[i], prev_start[i]);
+ if query[i - 1] != ' ' {
+ if prev[i - 1] < best {
+ best = prev[i - 1];
+ bs = prev_start[i - 1];
+ }
+ if cur[i - 1] < best {
+ best = cur[i - 1];
+ bs = cur_start[i - 1];
+ }
+ }
+ cur[i] = best;
+ cur_start[i] = bs;
+ }
+ } else {
+ for i in 1..=m {
+ let sub = prev[i - 1] + usize::from(query[i - 1] != t);
+ let del_text = prev[i] + 1; // extra text char
+ let del_query = cur[i - 1] + 1; // missing text char
+ let (mut best, mut bs) = (sub, prev_start[i - 1]);
+ if del_text < best {
+ best = del_text;
+ bs = prev_start[i];
+ }
+ if del_query < best {
+ best = del_query;
+ bs = cur_start[i - 1];
+ }
+ cur[i] = best;
+ cur_start[i] = bs;
+ }
+ }
+ if cur[m] <= max_cost {
+ ends.push(Hit {
+ start: cur_start[m],
+ end: j,
+ cost: cur[m],
+ });
+ }
+ std::mem::swap(&mut prev, &mut cur);
+ std::mem::swap(&mut prev_start, &mut cur_start);
+ }
+ summarize(ends)
+ }
+
+ #[test]
+ fn cut_off_matches_the_full_table() {
+ let alphabet = ['a', 'b', 'c', ' ', PLACEHOLDER];
+ let mut state = 0x9e37_79b9_7f4a_7c15_u64;
+ let mut next = |n: usize| {
+ state ^= state << 13;
+ state ^= state >> 7;
+ state ^= state << 17;
+ (state % n as u64) as usize
+ };
+ for _ in 0..30_000 {
+ let qn = 1 + next(30);
+ let query: Vec = (0..qn).map(|_| alphabet[next(4)]).collect();
+ let tn = 1 + next(80);
+ let text: Vec = (0..tn).map(|_| alphabet[next(5)]).collect();
+ let k = next(qn / 2 + 2);
+ assert_eq!(
+ align(&query, &text, k),
+ reference_align(&query, &text, k),
+ "{query:?} {text:?} {k}"
+ );
+ }
+ }
}
diff --git a/crates/proofback-anchor/src/classify.rs b/crates/proofback-anchor/src/classify.rs
index db638eb..876ceb4 100644
--- a/crates/proofback-anchor/src/classify.rs
+++ b/crates/proofback-anchor/src/classify.rs
@@ -49,7 +49,7 @@ pub fn classify(a: &PdfAnnotation) -> Classified {
Kind::Comment
}
}
- // A handwritten mark is a comment on what it covers (plan §4.3).
+ // A handwritten mark is a comment on what it covers (`docs/reference.md`, "PDF annotations").
"Ink" => Kind::Comment,
"Square" | "Circle" | "Polygon" | "PolyLine" | "Line" => Kind::General,
_ => Kind::General,
diff --git a/crates/proofback-anchor/src/ink.rs b/crates/proofback-anchor/src/ink.rs
index 526eb89..4814a49 100644
--- a/crates/proofback-anchor/src/ink.rs
+++ b/crates/proofback-anchor/src/ink.rs
@@ -1,7 +1,7 @@
//! Handwritten marks: `/Ink` annotations, the free strokes a tablet writes.
//!
//! Ink carries no text, so proofback anchors it to the source lines its bounding
-//! box covers and never claims an exact character range (D-14):
+//! box covers and never claims an exact character range:
//!
//! - strokes the application wrote as separate annotations are merged when they
//! share page and author and their boxes are closer than [`INK_MERGE_GAP`];
diff --git a/crates/proofback-anchor/src/lib.rs b/crates/proofback-anchor/src/lib.rs
index e1f72d0..9ecbd74 100644
--- a/crates/proofback-anchor/src/lib.rs
+++ b/crates/proofback-anchor/src/lib.rs
@@ -38,7 +38,7 @@ const CONTEXT: usize = 40;
/// Characters of source context stored in quote selectors.
const QUOTE_CONTEXT: usize = 32;
-/// Without SyncTeX, a match counts as "long" (plan §5.3) from this many folded
+/// Without SyncTeX, a match counts as "long" (`docs/reference.md`, "Without SyncTeX") from this many folded
/// characters; a shorter unique match is capped at `line`.
pub const LONG_MATCH_CHARS: usize = 20;
@@ -644,10 +644,9 @@ fn align_in_windows(
let min = all.iter().map(|h| h.2).min()?;
all.retain(|h| h.2 == min);
let top_line = cands.first().map(|c| (c.0.clone(), c.1));
- choose(input, all, min, second, &pre, &suf, top_line, query.len())
+ choose(input, all, min, second, &pre, &suf, top_line)
}
-#[allow(clippy::too_many_arguments)]
fn choose(
input: &Input<'_>,
mut hits: Vec<(String, Range, usize)>,
@@ -656,7 +655,6 @@ fn choose(
pre: &[char],
suf: &[char],
top_line: Option<(String, u32)>,
- qlen: usize,
) -> Option {
if hits.is_empty() {
return None;
@@ -723,7 +721,6 @@ fn choose(
.unwrap_or_else(|| scored[0].clone());
let src = input.sources.get(&pick.1)?;
let range = src.source_range_for_folded(pick.2)?;
- let _ = qlen;
Some((
pick.1,
range,
@@ -754,7 +751,7 @@ fn context_agreement(src: &SourceFile, r: &Range, pre: &[char], suf: &[ch
left + right
}
-/// Whether a unique match without SyncTeX is "long" (plan §5.3): the marked text
+/// Whether a unique match without SyncTeX is "long": the marked text
/// plus the PDF context that agrees with the source right next to it reach
/// [`LONG_MATCH_CHARS`].
pub fn is_long_match(marked_chars: usize, agreeing_context: usize) -> bool {
@@ -785,7 +782,7 @@ fn align_text_only(input: &Input<'_>, m: &MarkedText) -> Option {
.map_or(0, |src| context_agreement(src, r, &pre, &suf)),
_ => 0,
};
- let mut found = choose(input, hits, 0, None, &pre, &suf, None, qlen)?;
+ let mut found = choose(input, hits, 0, None, &pre, &suf, None)?;
// Without SyncTeX, short unique matches are only trusted to the line, unless the
// text around them in the PDF agrees with the source and makes them long.
if found.2 == Confidence::Exact && n == 1 && !is_long_match(qlen, agree) {
diff --git a/crates/proofback-anchor/src/locate.rs b/crates/proofback-anchor/src/locate.rs
index 6f7608f..5f210cf 100644
--- a/crates/proofback-anchor/src/locate.rs
+++ b/crates/proofback-anchor/src/locate.rs
@@ -1,6 +1,6 @@
//! The locator: a stateless query from a PDF position to a source range, through the
//! same pipeline as [`crate::import`] (SyncTeX candidates, then text alignment), and
-//! with the same honesty about confidence (D-14).
+//! with the same honesty about confidence.
use std::collections::HashMap;
diff --git a/crates/proofback-cli/Cargo.toml b/crates/proofback-cli/Cargo.toml
index af2b5d7..42b21c1 100644
--- a/crates/proofback-cli/Cargo.toml
+++ b/crates/proofback-cli/Cargo.toml
@@ -15,17 +15,17 @@ path = "src/main.rs"
[dependencies]
clap = { version = "4.6.10", features = ["derive"] }
-proofback-ai = { version = "0.3.0", path = "../proofback-ai" }
-proofback-anchor = { version = "0.3.0", path = "../proofback-anchor" }
-proofback-docx = { version = "0.3.0", path = "../proofback-docx" }
-proofback-emit = { version = "0.3.0", path = "../proofback-emit" }
-proofback-mcp = { version = "0.3.0", path = "../proofback-mcp" }
-proofback-model = { version = "0.3.0", path = "../proofback-model" }
-proofback-notes = { version = "0.3.0", path = "../proofback-notes" }
-proofback-pdf = { version = "0.3.0", path = "../proofback-pdf" }
-proofback-store = { version = "0.3.0", path = "../proofback-store" }
-proofback-synctex = { version = "0.3.0", path = "../proofback-synctex" }
-proofback-typst = { version = "0.3.0", path = "../proofback-typst", optional = true }
+proofback-ai = { version = "1.0.0", path = "../proofback-ai" }
+proofback-anchor = { version = "1.0.0", path = "../proofback-anchor" }
+proofback-docx = { version = "1.0.0", path = "../proofback-docx" }
+proofback-emit = { version = "1.0.0", path = "../proofback-emit" }
+proofback-mcp = { version = "1.0.0", path = "../proofback-mcp" }
+proofback-model = { version = "1.0.0", path = "../proofback-model" }
+proofback-notes = { version = "1.0.0", path = "../proofback-notes" }
+proofback-pdf = { version = "1.0.0", path = "../proofback-pdf" }
+proofback-store = { version = "1.0.0", path = "../proofback-store" }
+proofback-synctex = { version = "1.0.0", path = "../proofback-synctex" }
+proofback-typst = { version = "1.0.0", path = "../proofback-typst", optional = true }
ratatui = "0.30.2"
serde = "1.0.229"
serde_json = "1.0.154"
diff --git a/crates/proofback-cli/src/commands.rs b/crates/proofback-cli/src/commands.rs
index ed081df..16574e5 100644
--- a/crates/proofback-cli/src/commands.rs
+++ b/crates/proofback-cli/src/commands.rs
@@ -745,7 +745,7 @@ fn cmd_sync(p: &Project, json: bool, dry_run: bool, quiet: bool) -> Result bool {
p.config.hints && p.root.join("overfull.yml").is_file()
}
diff --git a/crates/proofback-cli/src/extract.rs b/crates/proofback-cli/src/extract.rs
index cfaf06e..ea24198 100644
--- a/crates/proofback-cli/src/extract.rs
+++ b/crates/proofback-cli/src/extract.rs
@@ -1,4 +1,4 @@
-//! PDF parsing in an isolated child process (plan section 10).
+//! PDF parsing in an isolated child process (threat model in `SECURITY.md`).
//!
//! The parent runs `proofback __extract `; the child lowers its own resource
//! limits, parses the PDF and prints [`proofback_pdf::Extracted`] as JSON. The parent
diff --git a/crates/proofback-cli/src/output.rs b/crates/proofback-cli/src/output.rs
index ccf28aa..bb4e290 100644
--- a/crates/proofback-cli/src/output.rs
+++ b/crates/proofback-cli/src/output.rs
@@ -177,7 +177,7 @@ pub fn table(items: &[&Item], style: &Style) -> String {
/// What `doctor` says when there is no SyncTeX file. The browser app shows the same
/// advice (`site/app/index.html`, `#synctex-notice`); the numbers are the text-only
-/// row of the accuracy table (plan §21.1).
+/// row of the accuracy table in `docs/reference.md`.
pub const SYNCTEX_ADVICE: &str = "no SyncTeX file found, so import runs in text-only mode \
(on the test corpus: exact words 98.7%, right line 98.0%; worse when the marked phrase repeats in your project). \
Build with `latexmk -pdf -synctex=1 main.tex`, or on Overleaf download output.synctex.gz from \
diff --git a/crates/proofback-cli/tests/e2e.rs b/crates/proofback-cli/tests/e2e.rs
index da042ac..40b3b99 100644
--- a/crates/proofback-cli/tests/e2e.rs
+++ b/crates/proofback-cli/tests/e2e.rs
@@ -781,8 +781,8 @@ fn letter_names_the_changes_pdf() {
assert!(err.contains("overfull diff --base"), "{err}");
}
-/// What `import` does with each PDF annotation subtype. README.md and PLAN §4.3
-/// carry the same table; `subtype_table_matches_readme` keeps them in step.
+/// What `import` does with each PDF annotation subtype. README.md and
+/// docs/reference.md carry the same table; `subtype_table_matches_readme` keeps them in step.
const SUBTYPES: &[(&str, &str)] = &[
("Highlight", "item"),
("StrikeOut", "item"),
@@ -994,10 +994,11 @@ fn subtype_table_matches_readme() {
let readme =
std::fs::read_to_string(Path::new(env!("CARGO_MANIFEST_DIR")).join("../../README.md"))
.unwrap();
- let plan =
- std::fs::read_to_string(Path::new(env!("CARGO_MANIFEST_DIR")).join("../../docs/PLAN.md"))
- .unwrap();
- for doc in [&readme, &plan] {
+ let reference = std::fs::read_to_string(
+ Path::new(env!("CARGO_MANIFEST_DIR")).join("../../docs/reference.md"),
+ )
+ .unwrap();
+ for doc in [&readme, &reference] {
for (subtype, result) in SUBTYPES {
let row = doc
.lines()
diff --git a/crates/proofback-corpus/Cargo.toml b/crates/proofback-corpus/Cargo.toml
index 7a92847..edc6d70 100644
--- a/crates/proofback-corpus/Cargo.toml
+++ b/crates/proofback-corpus/Cargo.toml
@@ -11,11 +11,11 @@ publish.workspace = true
[dependencies]
lopdf = { version = "0.47.0", default-features = false }
pdfium-render = { version = "0.9.6", default-features = false, features = ["pdfium_latest"] }
-proofback-anchor = { version = "0.3.0", path = "../proofback-anchor" }
-proofback-model = { version = "0.3.0", path = "../proofback-model" }
-proofback-pdf = { version = "0.3.0", path = "../proofback-pdf" }
-proofback-synctex = { version = "0.3.0", path = "../proofback-synctex" }
-proofback-tex = { version = "0.3.0", path = "../proofback-tex" }
+proofback-anchor = { version = "1.0.0", path = "../proofback-anchor" }
+proofback-model = { version = "1.0.0", path = "../proofback-model" }
+proofback-pdf = { version = "1.0.0", path = "../proofback-pdf" }
+proofback-synctex = { version = "1.0.0", path = "../proofback-synctex" }
+proofback-tex = { version = "1.0.0", path = "../proofback-tex" }
serde = { version = "1.0.229", features = ["derive"] }
serde_json = "1.0.154"
toml = "1.2.3"
diff --git a/crates/proofback-corpus/src/lib.rs b/crates/proofback-corpus/src/lib.rs
index 5e09d62..8244075 100644
--- a/crates/proofback-corpus/src/lib.rs
+++ b/crates/proofback-corpus/src/lib.rs
@@ -10,6 +10,19 @@
pub mod real;
+/// PDFium for tests, or `None` (with a note on stderr) when it is missing, unless
+/// `PROOFBACK_REQUIRE_PDFIUM` is set, in which case a missing PDFium fails the test.
+pub fn test_pdfium() -> Option {
+ match proofback_pdf::load_pdfium(None) {
+ Ok(p) => Some(p),
+ Err(e) if std::env::var_os("PROOFBACK_REQUIRE_PDFIUM").is_none() => {
+ eprintln!("skipping: {e}");
+ None
+ }
+ Err(e) => panic!("{e}"),
+ }
+}
+
use std::collections::HashMap;
use std::ops::Range;
use std::path::{Path, PathBuf};
@@ -633,7 +646,7 @@ pub enum Miss {
Macro,
/// Hyphenation, a ligature or other characters differ between PDF and source.
HyphenationOrLigature,
- /// Unique, but shorter than the length that counts as "long" (plan §5.3), so
+ /// Unique, but shorter than the length that counts as "long", so
/// capped at `line`. A split of "other".
ShortUnique,
/// None of the above.
diff --git a/crates/proofback-corpus/src/real.rs b/crates/proofback-corpus/src/real.rs
index fc06abf..466358c 100644
--- a/crates/proofback-corpus/src/real.rs
+++ b/crates/proofback-corpus/src/real.rs
@@ -8,7 +8,7 @@
//! - `truth.json`: for each annotation, the source range it refers to.
//!
//! [`load_all`] reads every donation, [`evaluate_real`] scores the import against the
-//! truth with the metrics of plan §12, and [`validate_dir`] checks a donation before
+//! truth with the accuracy metrics, and [`validate_dir`] checks a donation before
//! it is committed (`cargo xtask real-check `).
use std::collections::{BTreeMap, HashMap};
@@ -317,7 +317,7 @@ fn pct(x: f64) -> String {
format!("{:.1}%", x * 100.0)
}
-/// The metrics of plan §12 per application, as a plain-text table.
+/// The accuracy metrics per application, as a plain-text table.
pub fn table(report: &RealReport) -> String {
let mut rows = vec![[
"app".to_owned(),
diff --git a/crates/proofback-corpus/tests/accuracy.rs b/crates/proofback-corpus/tests/accuracy.rs
index 40a2e82..bbaebdb 100644
--- a/crates/proofback-corpus/tests/accuracy.rs
+++ b/crates/proofback-corpus/tests/accuracy.rs
@@ -1,4 +1,4 @@
-//! Accuracy gates from the plan (§12), on the synthetic corpus:
+//! Accuracy gates on the synthetic corpus (`docs/reference.md`, "Accuracy"):
//! - wrong-anchor rate under 1% (with and without SyncTeX);
//! - exact-range recall of at least 90% with SyncTeX;
//! - exact-range recall of at least [`TEXT_ONLY_EXACT_GATE`] without SyncTeX.
@@ -13,20 +13,11 @@ use proofback_corpus::{Fixture, Metrics, evaluate, generate};
/// when the gate was set (2026-12-01, issue #16).
const TEXT_ONLY_EXACT_GATE: f64 = 0.957;
-fn pdfium() -> Option {
- match proofback_pdf::load_pdfium(None) {
- Ok(p) => Some(p),
- Err(e) if std::env::var_os("PROOFBACK_REQUIRE_PDFIUM").is_none() => {
- eprintln!("skipping: {e}");
- None
- }
- Err(e) => panic!("{e}"),
- }
-}
-
#[test]
fn accuracy_gates() {
- let Some(pdfium) = pdfium() else { return };
+ let Some(pdfium) = proofback_corpus::test_pdfium() else {
+ return;
+ };
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures");
let mut with = Metrics::default();
let mut without = Metrics::default();
diff --git a/crates/proofback-corpus/tests/ink.rs b/crates/proofback-corpus/tests/ink.rs
index 9675071..e83346d 100644
--- a/crates/proofback-corpus/tests/ink.rs
+++ b/crates/proofback-corpus/tests/ink.rs
@@ -8,22 +8,13 @@ use std::path::Path;
use proofback_corpus::{Fixture, Metrics, evaluate, generate_ink};
-fn pdfium() -> Option {
- match proofback_pdf::load_pdfium(None) {
- Ok(p) => Some(p),
- Err(e) if std::env::var_os("PROOFBACK_REQUIRE_PDFIUM").is_none() => {
- eprintln!("skipping: {e}");
- None
- }
- Err(e) => panic!("{e}"),
- }
-}
-
/// Handwritten marks (`/Ink`), a separate set with its own metrics: never exact, the
/// wrong-anchor rate under 1% with and without SyncTeX.
#[test]
fn ink_set() {
- let Some(pdfium) = pdfium() else { return };
+ let Some(pdfium) = proofback_corpus::test_pdfium() else {
+ return;
+ };
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures");
let mut with = Metrics::default();
let mut without = Metrics::default();
diff --git a/crates/proofback-corpus/tests/locate.rs b/crates/proofback-corpus/tests/locate.rs
index ef3a81d..1f57cea 100644
--- a/crates/proofback-corpus/tests/locate.rs
+++ b/crates/proofback-corpus/tests/locate.rs
@@ -18,20 +18,11 @@ use proofback_model::Origin;
use proofback_model::locate::Query;
use proofback_pdf::{Limits, PageText, extract};
-fn pdfium() -> Option {
- match proofback_pdf::load_pdfium(None) {
- Ok(p) => Some(p),
- Err(e) if std::env::var_os("PROOFBACK_REQUIRE_PDFIUM").is_none() => {
- eprintln!("skipping: {e}");
- None
- }
- Err(e) => panic!("{e}"),
- }
-}
-
#[test]
fn locator_matches_import() {
- let Some(pdfium) = pdfium() else { return };
+ let Some(pdfium) = proofback_corpus::test_pdfium() else {
+ return;
+ };
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures");
let mut compared = 0;
for name in ["thesis-long", "article-twocolumn", "thesis-basic"] {
diff --git a/crates/proofback-corpus/tests/notes_accuracy.rs b/crates/proofback-corpus/tests/notes_accuracy.rs
index 9fecc99..e5b870f 100644
--- a/crates/proofback-corpus/tests/notes_accuracy.rs
+++ b/crates/proofback-corpus/tests/notes_accuracy.rs
@@ -1,4 +1,4 @@
-//! Notes corpus (plan section 16, M6): notes written the way reviewers write them,
+//! Notes corpus: notes written the way reviewers write them,
//! with ground truth from unique phrases and the document's section numbering.
//! Gate: wrong-anchor rate under 1%.
diff --git a/crates/proofback-corpus/tests/real.rs b/crates/proofback-corpus/tests/real.rs
index 1dc1904..d5289e0 100644
--- a/crates/proofback-corpus/tests/real.rs
+++ b/crates/proofback-corpus/tests/real.rs
@@ -1,5 +1,5 @@
//! The real-world set in `fixtures/real/` (PDFs annotated in real applications),
-//! reported separately from the synthetic corpus, with its gates (plan §12):
+//! reported separately from the synthetic corpus, with its gates:
//! - wrong-anchor rate under 1% (with and without SyncTeX);
//! - exact-range recall of at least [`REAL_EXACT_GATE`] with SyncTeX, once the set has
//! [`REAL_EXACT_MIN_ITEMS`] items.
@@ -32,17 +32,6 @@ fn pdfium_lock() -> std::sync::MutexGuard<'static, ()> {
.unwrap_or_else(std::sync::PoisonError::into_inner)
}
-fn pdfium() -> Option {
- match proofback_pdf::load_pdfium(None) {
- Ok(p) => Some(p),
- Err(e) if std::env::var_os("PROOFBACK_REQUIRE_PDFIUM").is_none() => {
- eprintln!("skipping: {e}");
- None
- }
- Err(e) => panic!("{e}"),
- }
-}
-
fn fixtures() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures")
}
@@ -136,7 +125,9 @@ fn empty_set_loads_as_no_data() {
#[test]
fn sample_donation_is_scored_per_app() {
let _pdfium = pdfium_lock();
- let Some(pdfium) = pdfium() else { return };
+ let Some(pdfium) = proofback_corpus::test_pdfium() else {
+ return;
+ };
let tmp = tempfile::tempdir().unwrap();
let (_, n) = sample(&pdfium, tmp.path());
let set = load_all(&tmp.path().join("real")).unwrap();
@@ -159,7 +150,9 @@ fn sample_donation_is_scored_per_app() {
#[test]
fn validation_accepts_a_clean_donation_and_rejects_names() {
let _pdfium = pdfium_lock();
- let Some(pdfium) = pdfium() else { return };
+ let Some(pdfium) = proofback_corpus::test_pdfium() else {
+ return;
+ };
let tmp = tempfile::tempdir().unwrap();
// The checks look for the project next to fixtures/real.
let root = tmp.path().join("fixtures");
@@ -247,7 +240,9 @@ fn real_world_set() {
return;
}
let _pdfium = pdfium_lock();
- let Some(pdfium) = pdfium() else { return };
+ let Some(pdfium) = proofback_corpus::test_pdfium() else {
+ return;
+ };
let with = evaluate_real(&set, &fixtures, &pdfium, true).unwrap();
let without = evaluate_real(&set, &fixtures, &pdfium, false).unwrap();
eprintln!(
diff --git a/crates/proofback-docx/Cargo.toml b/crates/proofback-docx/Cargo.toml
index 24cc6b6..7f411e5 100644
--- a/crates/proofback-docx/Cargo.toml
+++ b/crates/proofback-docx/Cargo.toml
@@ -9,9 +9,9 @@ homepage.workspace = true
publish.workspace = true
[dependencies]
-proofback-anchor = { version = "0.3.0", path = "../proofback-anchor" }
-proofback-model = { version = "0.3.0", path = "../proofback-model" }
-proofback-tex = { version = "0.3.0", path = "../proofback-tex" }
+proofback-anchor = { version = "1.0.0", path = "../proofback-anchor" }
+proofback-model = { version = "1.0.0", path = "../proofback-model" }
+proofback-tex = { version = "1.0.0", path = "../proofback-tex" }
quick-xml = "0.42.0"
thiserror = "2.0.21"
zip = { version = "9.7.3", default-features = false, features = ["deflate-flate2"] }
diff --git a/crates/proofback-docx/src/import.rs b/crates/proofback-docx/src/import.rs
index 0f6109c..d25a52b 100644
--- a/crates/proofback-docx/src/import.rs
+++ b/crates/proofback-docx/src/import.rs
@@ -590,7 +590,6 @@ fn locate(c: &Change, files: &[String], sources: &Sources) -> Located {
// Window: the bookmarked paragraph, or the whole project.
let bookmark = c.bookmark.as_deref().and_then(|b| parse_bookmark(b, files));
let (para_fold, para_origin) = fold_docx(&c.paragraph_text);
- let total_chars = c.paragraph_text.chars().count();
// Folded range of the change inside the paragraph.
let fstart = para_origin
.iter()
@@ -604,7 +603,6 @@ fn locate(c: &Change, files: &[String], sources: &Sources) -> Located {
let q_start = fstart.saturating_sub(ctx);
let q_end = (fend + ctx).min(para_fold.len());
let query: Vec = para_fold[q_start..q_end].to_vec();
- let _ = total_chars;
if query.iter().filter(|c| c.is_alphanumeric()).count() < 4 {
return (
None,
diff --git a/crates/proofback-docx/src/tests.rs b/crates/proofback-docx/src/tests.rs
index 3199b71..105251c 100644
--- a/crates/proofback-docx/src/tests.rs
+++ b/crates/proofback-docx/src/tests.rs
@@ -265,7 +265,7 @@ fn rejects_non_docx() {
assert!(import(b"not a zip", &Sources::default(), "r").is_err());
}
-/// M7 exit criterion: round trip on fixtures with at least 90% exact anchors and
+/// Round trip on fixtures with at least 90% exact anchors and
/// no wrong ones.
#[test]
fn round_trip_corpus_meets_the_gate() {
diff --git a/crates/proofback-emit/Cargo.toml b/crates/proofback-emit/Cargo.toml
index d12fd7c..ebe2a44 100644
--- a/crates/proofback-emit/Cargo.toml
+++ b/crates/proofback-emit/Cargo.toml
@@ -9,8 +9,8 @@ homepage.workspace = true
publish.workspace = true
[dependencies]
-proofback-model = { version = "0.3.0", path = "../proofback-model" }
-proofback-pdf = { version = "0.3.0", path = "../proofback-pdf" }
+proofback-model = { version = "1.0.0", path = "../proofback-model" }
+proofback-pdf = { version = "1.0.0", path = "../proofback-pdf" }
serde_json = "1.0.154"
[lints]
diff --git a/crates/proofback-mcp/Cargo.toml b/crates/proofback-mcp/Cargo.toml
index 59811ff..3f20d22 100644
--- a/crates/proofback-mcp/Cargo.toml
+++ b/crates/proofback-mcp/Cargo.toml
@@ -9,10 +9,10 @@ homepage.workspace = true
publish.workspace = true
[dependencies]
-proofback-anchor = { version = "0.3.0", path = "../proofback-anchor" }
-proofback-emit = { version = "0.3.0", path = "../proofback-emit" }
-proofback-model = { version = "0.3.0", path = "../proofback-model" }
-proofback-store = { version = "0.3.0", path = "../proofback-store" }
+proofback-anchor = { version = "1.0.0", path = "../proofback-anchor" }
+proofback-emit = { version = "1.0.0", path = "../proofback-emit" }
+proofback-model = { version = "1.0.0", path = "../proofback-model" }
+proofback-store = { version = "1.0.0", path = "../proofback-store" }
serde_json = "1.0.154"
[lints]
diff --git a/crates/proofback-model/tests/frozen_schemas.rs b/crates/proofback-model/tests/frozen_schemas.rs
new file mode 100644
index 0000000..1c49171
--- /dev/null
+++ b/crates/proofback-model/tests/frozen_schemas.rs
@@ -0,0 +1,37 @@
+//! The published schemas are frozen from 1.0 (docs/stability.md). The generated
+//! schema must equal the committed file (also checked by `cargo xtask schema --check`),
+//! and the committed file must not change without a review against docs/stability.md:
+//! a change here is either additive and approved there, or needs a new major version.
+
+use sha2::{Digest, Sha256};
+
+fn sha256(s: &str) -> String {
+ Sha256::digest(s.as_bytes())
+ .iter()
+ .map(|b| format!("{b:02x}"))
+ .collect()
+}
+
+fn generated(v: &serde_json::Value) -> String {
+ let mut s = serde_json::to_string_pretty(v).expect("schema serialises");
+ s.push('\n');
+ s
+}
+
+#[test]
+fn round_file_schema_v1_is_frozen() {
+ assert_eq!(
+ sha256(&generated(&proofback_model::round_file_schema())),
+ "73ee1c5ded74eb03be828362ba93df23a5220000c08fd0583637da4d61d2a64f",
+ "site/schema/v1.json changed: see docs/stability.md"
+ );
+}
+
+#[test]
+fn locate_schema_v1_is_frozen() {
+ assert_eq!(
+ sha256(&generated(&proofback_model::locate::locate_schema())),
+ "cef6552cf7e56143461627fa522a326b788131eed4bee37fd62c4cc300a8ae7a",
+ "site/schema/locate-v1.json changed: see docs/stability.md"
+ );
+}
diff --git a/crates/proofback-notes/Cargo.toml b/crates/proofback-notes/Cargo.toml
index 9050563..b075991 100644
--- a/crates/proofback-notes/Cargo.toml
+++ b/crates/proofback-notes/Cargo.toml
@@ -9,10 +9,10 @@ homepage.workspace = true
publish.workspace = true
[dependencies]
-proofback-anchor = { version = "0.3.0", path = "../proofback-anchor" }
-proofback-model = { version = "0.3.0", path = "../proofback-model" }
-proofback-synctex = { version = "0.3.0", path = "../proofback-synctex" }
-proofback-tex = { version = "0.3.0", path = "../proofback-tex" }
+proofback-anchor = { version = "1.0.0", path = "../proofback-anchor" }
+proofback-model = { version = "1.0.0", path = "../proofback-model" }
+proofback-synctex = { version = "1.0.0", path = "../proofback-synctex" }
+proofback-tex = { version = "1.0.0", path = "../proofback-tex" }
regex = "1.13.2"
serde = { version = "1.0.229", features = ["derive"] }
serde_json = "1.0.154"
diff --git a/crates/proofback-store/Cargo.toml b/crates/proofback-store/Cargo.toml
index 8ffe447..5635cbb 100644
--- a/crates/proofback-store/Cargo.toml
+++ b/crates/proofback-store/Cargo.toml
@@ -9,8 +9,8 @@ homepage.workspace = true
publish.workspace = true
[dependencies]
-proofback-anchor = { version = "0.3.0", path = "../proofback-anchor" }
-proofback-model = { version = "0.3.0", path = "../proofback-model" }
+proofback-anchor = { version = "1.0.0", path = "../proofback-anchor" }
+proofback-model = { version = "1.0.0", path = "../proofback-model" }
serde = { version = "1.0.229", features = ["derive"] }
sha2 = "0.11.0"
similar = "3.2.1"
diff --git a/crates/proofback-store/src/config.rs b/crates/proofback-store/src/config.rs
index ace08eb..19e6005 100644
--- a/crates/proofback-store/src/config.rs
+++ b/crates/proofback-store/src/config.rs
@@ -90,7 +90,7 @@ impl Config {
pub fn to_toml(&self) -> String {
let body = toml::to_string_pretty(self).expect("config serialises");
- format!("# proofback project configuration. See docs/PLAN.md section 7.\n{body}")
+ format!("# proofback project configuration. See docs/reference.md.\n{body}")
}
}
diff --git a/crates/proofback-store/src/views.rs b/crates/proofback-store/src/views.rs
index adb8f06..574c0c5 100644
--- a/crates/proofback-store/src/views.rs
+++ b/crates/proofback-store/src/views.rs
@@ -1,7 +1,7 @@
//! JSON views of items for people and agents.
//!
//! Reviewer text is returned inside `untrusted_reviewer_text` so that agents can
-//! tell data from instructions (prompt-injection defence, plan section 8).
+//! tell data from instructions (prompt-injection defence, see `SECURITY.md`).
use proofback_anchor::Sources;
use proofback_model::{Item, Origin};
diff --git a/crates/proofback-synctex/Cargo.toml b/crates/proofback-synctex/Cargo.toml
index a5c44d3..def2f52 100644
--- a/crates/proofback-synctex/Cargo.toml
+++ b/crates/proofback-synctex/Cargo.toml
@@ -10,6 +10,7 @@ publish.workspace = true
[dependencies]
flate2 = "1.1.11"
+memchr = "2.8.3"
thiserror = "2.0.21"
[lints]
diff --git a/crates/proofback-synctex/src/lib.rs b/crates/proofback-synctex/src/lib.rs
index 4871e9c..8f68c2b 100644
--- a/crates/proofback-synctex/src/lib.rs
+++ b/crates/proofback-synctex/src/lib.rs
@@ -159,13 +159,16 @@ pub struct Hit {
impl SyncTex {
/// Parse `SyncTeX` data, transparently decompressing gzip input.
pub fn parse(reader: R, limits: Limits) -> Result {
- let mut buffered = BufReader::new(reader);
+ let mut buffered = BufReader::with_capacity(64 * 1024, reader);
let is_gzip = {
let head = buffered.fill_buf()?;
head.len() >= 2 && head[0] == 0x1f && head[1] == 0x8b
};
if is_gzip {
- Parser::new(limits).run(BufReader::new(MultiGzDecoder::new(buffered)))
+ Parser::new(limits).run(BufReader::with_capacity(
+ 64 * 1024,
+ MultiGzDecoder::new(buffered),
+ ))
} else {
Parser::new(limits).run(buffered)
}
@@ -431,6 +434,72 @@ impl Parser {
while matches!(buf.last(), Some(b'\n' | b'\r')) {
buf.pop();
}
+ let Some(&first) = buf.first() else {
+ if seen_header {
+ continue;
+ }
+ return Err(Error::NotSyncTex);
+ };
+
+ // Node records are most of the file: parse them as bytes. No preamble
+ // key starts with one of these characters, so checking them first does
+ // not change which lines are keys.
+ if seen_header
+ && matches!(
+ first,
+ b'[' | b'(' | b'v' | b'h' | b'x' | b'k' | b'g' | b'$' | b'r'
+ )
+ {
+ let Some(page) = current.as_mut() else {
+ continue;
+ };
+ let kind = match first {
+ b'[' => Kind::VBox,
+ b'(' => Kind::HBox,
+ b'v' => Kind::VoidVBox,
+ b'h' => Kind::VoidHBox,
+ b'x' => Kind::Current,
+ b'k' => Kind::Kern,
+ b'g' => Kind::Glue,
+ b'$' => Kind::Math,
+ _ => Kind::Rule,
+ };
+ let Some(fields) = parse_node(&buf[1..]) else {
+ return Err(Error::Malformed {
+ line: line_no,
+ reason: "node record",
+ });
+ };
+ self.records += 1;
+ if self.records > self.limits.max_records {
+ return Err(Error::LimitExceeded {
+ what: "record count",
+ limit: self.limits.max_records as u64,
+ });
+ }
+ let x_off = self.x_offset;
+ let y_off = self.y_offset;
+ let rec = Record {
+ kind,
+ tag: fields.tag,
+ line: fields.line,
+ column: fields.column,
+ // Offsets come from the file: saturate rather than overflow.
+ x: self.to_bp(fields.x.saturating_add(x_off as i64)),
+ y: self.to_bp(fields.y.saturating_add(y_off as i64)),
+ width: self.to_bp(fields.w),
+ height: self.to_bp(fields.h),
+ depth: self.to_bp(fields.d),
+ parent: stack.last().copied(),
+ };
+ let idx = page.records.len() as u32;
+ page.records.push(rec);
+ if matches!(kind, Kind::VBox | Kind::HBox) {
+ stack.push(idx);
+ }
+ continue;
+ }
+
let line = String::from_utf8_lossy(&buf);
let line = line.as_ref();
@@ -441,9 +510,6 @@ impl Parser {
}
return Err(Error::NotSyncTex);
}
- if line.is_empty() {
- continue;
- }
// Preamble and postamble key/value lines, plus inputs that may appear
// anywhere in the content.
@@ -476,7 +542,6 @@ impl Parser {
continue;
}
- let first = line.as_bytes()[0];
match first {
b'{' => {
let number: u32 = line[1..].parse().map_err(|_| Error::Malformed {
@@ -504,55 +569,6 @@ impl Parser {
b']' | b')' => {
stack.pop();
}
- b'[' | b'(' | b'v' | b'h' | b'x' | b'k' | b'g' | b'$' | b'r' => {
- let Some(page) = current.as_mut() else {
- continue;
- };
- let kind = match first {
- b'[' => Kind::VBox,
- b'(' => Kind::HBox,
- b'v' => Kind::VoidVBox,
- b'h' => Kind::VoidHBox,
- b'x' => Kind::Current,
- b'k' => Kind::Kern,
- b'g' => Kind::Glue,
- b'$' => Kind::Math,
- _ => Kind::Rule,
- };
- let Some(fields) = parse_node(&line[1..]) else {
- return Err(Error::Malformed {
- line: line_no,
- reason: "node record",
- });
- };
- self.records += 1;
- if self.records > self.limits.max_records {
- return Err(Error::LimitExceeded {
- what: "record count",
- limit: self.limits.max_records as u64,
- });
- }
- let x_off = self.x_offset;
- let y_off = self.y_offset;
- let rec = Record {
- kind,
- tag: fields.tag,
- line: fields.line,
- column: fields.column,
- // Offsets come from the file: saturate rather than overflow.
- x: self.to_bp(fields.x.saturating_add(x_off as i64)),
- y: self.to_bp(fields.y.saturating_add(y_off as i64)),
- width: self.to_bp(fields.w),
- height: self.to_bp(fields.h),
- depth: self.to_bp(fields.d),
- parent: stack.last().copied(),
- };
- let idx = page.records.len() as u32;
- page.records.push(rec);
- if matches!(kind, Kind::VBox | Kind::HBox) {
- stack.push(idx);
- }
- }
// Byte counts, form references and anything newer we do not need.
_ => {}
}
@@ -582,23 +598,29 @@ struct NodeFields {
}
/// Parse `tag,line[,column]:x,y[:W[,H,D]]`.
-fn parse_node(s: &str) -> Option {
- let mut parts = s.split(':');
+///
+/// Numbers follow the rules of `str::parse`: an optional sign (`+` only for the
+/// unsigned fields), then ASCII digits, with overflow rejected. A missing or invalid
+/// column is `None`; a missing or invalid size component is 0; anything after a
+/// third `:` is ignored.
+fn parse_node(s: &[u8]) -> Option {
+ let mut parts = s.split(|&b| b == b':');
let link = parts.next()?;
let pos = parts.next()?;
let size = parts.next();
- let mut l = link.split(',');
- let tag = l.next()?.parse().ok()?;
- let line = l.next()?.parse().ok()?;
- let column = l.next().and_then(|c| c.parse().ok());
- let (x, y) = pos.split_once(',')?;
- let (x, y) = (x.parse().ok()?, y.parse().ok()?);
+ let mut l = link.split(|&b| b == b',');
+ let tag = parse_u32(l.next()?)?;
+ let line = parse_u32(l.next()?)?;
+ let column = l.next().and_then(parse_u32);
+ let comma = pos.iter().position(|&b| b == b',')?;
+ let x = parse_i64(&pos[..comma])?;
+ let y = parse_i64(&pos[comma + 1..])?;
let (mut w, mut h, mut d) = (0, 0, 0);
if let Some(size) = size {
- let mut it = size.split(',');
- w = it.next().and_then(|v| v.parse().ok()).unwrap_or(0);
- h = it.next().and_then(|v| v.parse().ok()).unwrap_or(0);
- d = it.next().and_then(|v| v.parse().ok()).unwrap_or(0);
+ let mut it = size.split(|&b| b == b',');
+ w = it.next().and_then(parse_i64).unwrap_or(0);
+ h = it.next().and_then(parse_i64).unwrap_or(0);
+ d = it.next().and_then(parse_i64).unwrap_or(0);
}
Some(NodeFields {
tag,
@@ -612,6 +634,50 @@ fn parse_node(s: &str) -> Option {
})
}
+/// Digits with an optional leading `+`, as `u32::from_str` accepts them.
+fn parse_u32(s: &[u8]) -> Option {
+ let digits = s.strip_prefix(b"+").unwrap_or(s);
+ if digits.is_empty() {
+ return None;
+ }
+ let mut v: u32 = 0;
+ for &b in digits {
+ let d = b.wrapping_sub(b'0');
+ if d > 9 {
+ return None;
+ }
+ v = v.checked_mul(10)?.checked_add(u32::from(d))?;
+ }
+ Some(v)
+}
+
+/// Digits with an optional leading `+` or `-`, as `i64::from_str` accepts them.
+fn parse_i64(s: &[u8]) -> Option {
+ let (negative, digits) = match s.first() {
+ Some(b'-') => (true, &s[1..]),
+ Some(b'+') => (false, &s[1..]),
+ _ => (false, s),
+ };
+ if digits.is_empty() {
+ return None;
+ }
+ let mut v: i64 = 0;
+ for &b in digits {
+ let d = b.wrapping_sub(b'0');
+ if d > 9 {
+ return None;
+ }
+ // Accumulate towards the sign so that `i64::MIN` parses.
+ v = v.checked_mul(10)?;
+ v = if negative {
+ v.checked_sub(i64::from(d))?
+ } else {
+ v.checked_add(i64::from(d))?
+ };
+ }
+ Some(v)
+}
+
/// Read one line, failing if it is longer than `max` bytes.
fn read_line_limited(r: &mut R, buf: &mut Vec, max: usize) -> Result {
let mut read = 0;
@@ -620,7 +686,7 @@ fn read_line_limited(r: &mut R, buf: &mut Vec, max: usize) -> Re
if available.is_empty() {
return Ok(read);
}
- let (chunk, done) = match available.iter().position(|&b| b == b'\n') {
+ let (chunk, done) = match memchr::memchr(b'\n', available) {
Some(i) => (&available[..=i], true),
None => (available, false),
};
@@ -646,6 +712,87 @@ mod tests {
const SAMPLE: &str = "SyncTeX Version:1\nInput:1:/work/thesis/./main.tex\nInput:2:/usr/share/texmf/report.cls\nInput:3:/work/thesis/./chapters/a.tex\nOutput:pdf\nMagnification:1000\nUnit:1\nX Offset:0\nY Offset:0\nContent:\n!100\n{1\n[1,5:4736286,45984660:27131904,41248374,0\n(3,4:4736286,10000000:27131904,500000,100000\nx3,4:4736286,10000000\ng3,4:9000000,10000000\nx3,5:15000000,10000000\nk3,5:20000000,10000000:100\n)\n(3,6:4736286,12000000:27131904,500000,100000\nx3,6:4736286,12000000\n$3,7:10000000,12000000\n)\n]\n}1\n!20\nPostamble:\nCount:9\n";
+ /// The `str::parse` implementation the byte parser replaced.
+ fn reference_node(s: &str) -> Option<(u32, u32, Option, i64, i64, i64, i64, i64)> {
+ let mut parts = s.split(':');
+ let link = parts.next()?;
+ let pos = parts.next()?;
+ let size = parts.next();
+ let mut l = link.split(',');
+ let tag = l.next()?.parse().ok()?;
+ let line = l.next()?.parse().ok()?;
+ let column = l.next().and_then(|c| c.parse().ok());
+ let (x, y) = pos.split_once(',')?;
+ let (x, y) = (x.parse().ok()?, y.parse().ok()?);
+ let (mut w, mut h, mut d) = (0, 0, 0);
+ if let Some(size) = size {
+ let mut it = size.split(',');
+ w = it.next().and_then(|v| v.parse().ok()).unwrap_or(0);
+ h = it.next().and_then(|v| v.parse().ok()).unwrap_or(0);
+ d = it.next().and_then(|v| v.parse().ok()).unwrap_or(0);
+ }
+ Some((tag, line, column, x, y, w, h, d))
+ }
+
+ #[test]
+ fn byte_parser_matches_str_parse() {
+ let pieces = [
+ "0",
+ "1",
+ "42",
+ "-7",
+ "+7",
+ "+",
+ "-",
+ "",
+ "-0",
+ "+-1",
+ "4294967295",
+ "4294967296",
+ "9223372036854775807",
+ "9223372036854775808",
+ "-9223372036854775808",
+ "-9223372036854775809",
+ "1a",
+ " 1",
+ "x",
+ ",",
+ ":",
+ "\u{e9}",
+ "07",
+ ];
+ // A small deterministic generator: no extra dependencies.
+ let mut state = 0x2545_f491_4f6c_dd1d_u64;
+ let mut next = |n: usize| {
+ state ^= state << 13;
+ state ^= state >> 7;
+ state ^= state << 17;
+ (state % n as u64) as usize
+ };
+ for _ in 0..200_000 {
+ let mut s = String::new();
+ for _ in 0..next(12) {
+ s.push_str(pieces[next(pieces.len())]);
+ s.push_str([",", ":", ""][next(3)]);
+ }
+ let got = parse_node(s.as_bytes())
+ .map(|f| (f.tag, f.line, f.column, f.x, f.y, f.w, f.h, f.d));
+ assert_eq!(got, reference_node(&s), "{s:?}");
+ }
+ for s in [
+ "1,2:3,4",
+ "1,2,3:-4,+5:6,7,8",
+ "1,2:3,4:",
+ "1,2:3,4:x,9",
+ "1,2:3,4:5:6",
+ ] {
+ let got = parse_node(s.as_bytes())
+ .map(|f| (f.tag, f.line, f.column, f.x, f.y, f.w, f.h, f.d));
+ assert_eq!(got, reference_node(s), "{s:?}");
+ assert!(got.is_some(), "{s:?}");
+ }
+ }
+
fn sample() -> SyncTex {
SyncTex::parse(SAMPLE.as_bytes(), Limits::default()).unwrap()
}
diff --git a/crates/proofback-tex/src/fold.rs b/crates/proofback-tex/src/fold.rs
index 53c52bc..f5fae9a 100644
--- a/crates/proofback-tex/src/fold.rs
+++ b/crates/proofback-tex/src/fold.rs
@@ -13,6 +13,11 @@ pub struct Folded {
///
/// Lower-cases, unifies quotes, dashes and spaces, and expands ligatures.
pub fn fold_char(c: char, out: &mut Vec) {
+ // Most text is ASCII: skip the Unicode tables.
+ if c.is_ascii() {
+ out.push(fold_ascii(c));
+ return;
+ }
match c {
'\u{2018}' | '\u{2019}' | '\u{201A}' | '\u{201B}' | '\u{2032}' | '`' | '´' => {
out.push('\'');
@@ -35,11 +40,28 @@ pub fn fold_char(c: char, out: &mut Vec) {
}
}
+/// [`fold_char`] for an ASCII character, which always folds to exactly one.
+fn fold_ascii(c: char) -> char {
+ match c {
+ '`' => '\'',
+ '\t' | '\n' | '\r' => ' ',
+ c => c.to_ascii_lowercase(),
+ }
+}
+
/// Fold a sequence of characters, collapsing runs of spaces.
pub fn fold_str>(chars: I) -> Folded {
let mut f = Folded::default();
let mut tmp = Vec::with_capacity(3);
for (i, c) in chars.into_iter().enumerate() {
+ if c.is_ascii() {
+ let fc = fold_ascii(c);
+ if !(fc == ' ' && matches!(f.chars.last(), None | Some(' '))) {
+ f.chars.push(fc);
+ f.origin.push(i);
+ }
+ continue;
+ }
tmp.clear();
fold_char(c, &mut tmp);
for &fc in &tmp {
@@ -52,3 +74,23 @@ pub fn fold_str>(chars: I) -> Folded {
}
f
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn ascii_fast_path_matches_the_general_rules() {
+ for b in 0u8..128 {
+ let c = char::from(b);
+ let expected: Vec = match c {
+ '`' => vec!['\''],
+ '\t' | '\n' | '\r' => vec![' '],
+ c => c.to_lowercase().collect(),
+ };
+ let mut out = Vec::new();
+ fold_char(c, &mut out);
+ assert_eq!(out, expected, "{c:?}");
+ }
+ }
+}
diff --git a/crates/proofback-typst/Cargo.toml b/crates/proofback-typst/Cargo.toml
index 5019311..906eccf 100644
--- a/crates/proofback-typst/Cargo.toml
+++ b/crates/proofback-typst/Cargo.toml
@@ -9,10 +9,10 @@ homepage.workspace = true
publish.workspace = true
[dependencies]
-proofback-anchor = { version = "0.3.0", path = "../proofback-anchor" }
-proofback-model = { version = "0.3.0", path = "../proofback-model" }
-proofback-pdf = { version = "0.3.0", path = "../proofback-pdf" }
-proofback-tex = { version = "0.3.0", path = "../proofback-tex" }
+proofback-anchor = { version = "1.0.0", path = "../proofback-anchor" }
+proofback-model = { version = "1.0.0", path = "../proofback-model" }
+proofback-pdf = { version = "1.0.0", path = "../proofback-pdf" }
+proofback-tex = { version = "1.0.0", path = "../proofback-tex" }
typst = "0.15.1"
typst-assets = { version = "0.15.1", features = ["fonts"] }
typst-layout = "0.15.1"
diff --git a/crates/proofback-typst/tests/corpus.rs b/crates/proofback-typst/tests/corpus.rs
index 6bcf768..1e0c721 100644
--- a/crates/proofback-typst/tests/corpus.rs
+++ b/crates/proofback-typst/tests/corpus.rs
@@ -1,4 +1,4 @@
-//! Typst accuracy (plan section 16, M8): the LaTeX gates apply. Needs PDFium.
+//! Typst accuracy: the LaTeX gates apply. Needs PDFium.
use std::collections::HashMap;
use std::path::Path;
diff --git a/crates/proofback-wasm/Cargo.toml b/crates/proofback-wasm/Cargo.toml
index 6abed14..650b9f8 100644
--- a/crates/proofback-wasm/Cargo.toml
+++ b/crates/proofback-wasm/Cargo.toml
@@ -13,12 +13,12 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
pdfium-render = { version = "0.9.6", default-features = false, features = ["pdfium_latest"] }
-proofback-anchor = { version = "0.3.0", path = "../proofback-anchor" }
-proofback-emit = { version = "0.3.0", path = "../proofback-emit" }
-proofback-model = { version = "0.3.0", path = "../proofback-model" }
-proofback-pdf = { version = "0.3.0", path = "../proofback-pdf" }
-proofback-store = { version = "0.3.0", path = "../proofback-store" }
-proofback-synctex = { version = "0.3.0", path = "../proofback-synctex" }
+proofback-anchor = { version = "1.0.0", path = "../proofback-anchor" }
+proofback-emit = { version = "1.0.0", path = "../proofback-emit" }
+proofback-model = { version = "1.0.0", path = "../proofback-model" }
+proofback-pdf = { version = "1.0.0", path = "../proofback-pdf" }
+proofback-store = { version = "1.0.0", path = "../proofback-store" }
+proofback-synctex = { version = "1.0.0", path = "../proofback-synctex" }
serde_json = "1.0.154"
wasm-bindgen = "=0.2.130"
zip = { version = "9.7.3", default-features = false, features = ["deflate-flate2"] }
diff --git a/docs/PLAN.md b/docs/PLAN.md
deleted file mode 100644
index e5879d3..0000000
--- a/docs/PLAN.md
+++ /dev/null
@@ -1,850 +0,0 @@
-# proofback: project plan
-
-**Every margin note, back in your source.**
-
-proofback takes the feedback a reviewer leaves on a compiled PDF (highlights,
-strike-outs, carets, sticky notes, and later email notes and Word tracked changes),
-finds the exact file, line and character range of the LaTeX source each item refers
-to, tracks what the author did about it across drafts, and sends the answers back.
-
-| | |
-|---|---|
-| Status | Implemented through M8 (v1.1 of this document). Deviations from v1.0 and measured results: [§21](#21-implementation-notes). |
-| Website | |
-| Licence | MIT OR Apache-2.0 |
-| Decisions | Numbered `D-xx`, collected in [§20](#20-decision-log) |
-| Audit | Findings from the plan review and how each was resolved: [§19](#19-audit-and-grill-log) |
-
----
-
-## 1. Problem
-
-Supervisors, co-authors, peer reviewers and proofreaders do not edit `.tex` files.
-They read the PDF and mark it up in Acrobat, Preview, Zotero, Okular, PDF Expert or
-a tablet app, or they send an email that lists page numbers. The author then:
-
-1. opens the annotated PDF next to the editor,
-2. finds each mark by eye,
-3. searches for the matching sentence across a tree of `\input` files,
-4. edits, and tries to remember what was done, skipped or disputed,
-5. writes the replies by hand.
-
-This repeats for every chapter and every draft of a thesis, and ends in a
-hand-written response letter for a paper. Comments get lost, replies drift away
-from what actually changed, and the reviewer cannot check.
-
-### 1.1 What exists (surveyed November 2026)
-
-| Tool | What it does | What is missing |
-|---|---|---|
-| pdfannots | Extracts PDF annotations to Markdown with page and quoted text | No source file or line |
-| LaTeX Workshop, TeXstudio, Skim, Okular, Emacs pdf-tools | SyncTeX jump for one location at a time | No bulk import, no tracking |
-| pandoc `--track-changes` | DOCX to LaTeX keeping insertions and deletions | Produces a new `.tex`; the author's source and formatting are lost |
-| Overleaf, OpenAI Prism | Comments and track changes inside the platform | Every reviewer must adopt the platform; no PDF or Word input |
-| Small 2026 AI "skills" | An LLM re-applies Word edits to `.tex` | Non-deterministic, no anchors, no tracking |
-
-**Gap:** nothing turns feedback in the formats reviewers actually use into a
-precise, trackable list of changes against the author's existing source.
-
-### 1.2 Non-goals
-
-- Pre-submission checking (references, PDF problems, venue rules, templates). That is
- [overfull](https://github.com/Amet13/overfull). proofback starts after someone has
- read the document. The tools share conventions (JSON shape, `--json`, agent docs),
- not code or features (D-01).
-- Being an editor, a collaboration platform, or a hosted service.
-- Grammar or style checking, or generating content.
-
----
-
-## 2. Users and workflows
-
-- **Author** (primary): keeps LaTeX in a folder or git repository, possibly synced
- with Overleaf.
-- **Reviewer**: never installs anything and keeps their own tools.
-- **Coding agent**: acts for the author through the CLI or MCP server.
-
-Theses are the flagship story. Any reviewed LaTeX document is supported (D-02).
-
-### W1. Annotated PDF to checklist (v0.1)
-
-```bash
-proofback import review-ch3.pdf --round supervisor-2026-11
-proofback list
-```
-
-```
-id where kind note anchor
-pb_7k2m9q chapters/method.tex:41:18-23 replace Replace with "robust" exact
-pb_q81fza chapters/method.tex:42:17-40 comment Cite the field study here exact
-pb_3xq1fd chapters/method.tex:44:1-13 question Why this threshold? exact
-pb_d0r4kl chapters/method.tex:45:1-46:34 delete (strike-out, no note) exact
-pb_m2h7tq p. 15, figure 3.2 comment Axis labels unreadable region
-```
-
-### W2. Work through it, alone or with an agent (v0.2, v0.3)
-
-```bash
-proofback patch pb_7k2m9q pb_d0r4kl | git apply
-proofback resolve pb_3xq1fd --status discuss --reply "Chosen by 5-fold CV, see 3.4"
-proofback resolve pb_m2h7tq --status wontfix --reply "Figure is regenerated in the next draft"
-proofback triage # keyboard UI for confirming low-confidence items
-```
-
-IDs accept unique prefixes, like git (`pb_7k2`). In Claude Code, Codex or Cursor:
-"work through the open proofback items in chapter 3". The agent uses the MCP server,
-proposes edits and records replies.
-
-### W3. Send the answers back (v0.2)
-
-```bash
-proofback answer -o review-ch3-answered.pdf # reviewer's own PDF, reply on every note
-proofback letter --format latex > response.tex
-```
-
-### W4. Next draft (v0.2)
-
-`proofback sync` re-anchors every open item in the current source and reports
-items that moved, changed (probably addressed) or were lost.
-
-### W5. Notes from an email (v0.5)
-
-```bash
-proofback import notes.txt # "p. 12, para 2: unclear", "3.1: 'state of the art' -> 'current'"
-```
-
-### W6. No terminal (v0.4)
-
-Open , drop the annotated PDF, the
-`.synctex.gz` and the sources (folder or Overleaf zip). Everything runs locally in
-WebAssembly. Nothing is uploaded.
-
-### W7. Word round trip (v0.6)
-
-```bash
-proofback docx export -o thesis-for-review.docx # hidden source anchors embedded
-proofback import thesis-reviewed.docx # tracked changes and comments become items
-```
-
-### W8. Pull request review (v0.3)
-
-A GitHub Action imports a review PDF committed to the repository and posts each item
-as an inline review comment on the right line.
-
----
-
-## 3. Product surfaces (D-03)
-
-| Surface | Version | Notes |
-|---|---|---|
-| CLI `proofback` | v0.1 | Single binary for Linux, macOS, Windows (x86-64 and arm64); `--json` everywhere |
-| `proofback triage` | v0.2 | Terminal UI (ratatui) for confirming and resolving items |
-| MCP server `proofback mcp` | v0.3 | stdio transport only |
-| Agent kit | v0.3 | Agent Skill (`SKILL.md`), Claude Code plugin, `AGENTS.md` snippet, Cursor rules, `llms.txt` |
-| GitHub Action | v0.3 | Review comments and job summary |
-| Browser app | v0.4 | Same Rust core as WebAssembly, under `/app` on the website |
-| npm package | v0.4 | WebAssembly build for Node 20+ and `npx proofback` |
-| VS Code extension | v0.7 | Tree view, gutter marks, apply, reply |
-| Typst | v0.8 | Through the Typst compiler's span API |
-
----
-
-## 4. Architecture
-
-### 4.1 Language (D-04)
-
-One Rust core, built for native targets (CLI, MCP, Action) and `wasm32-unknown-unknown`
-(browser, npm). The browser and the CLI therefore give identical answers and share one
-golden test suite. Rust over TypeScript: speed on large theses, a single static binary
-without a runtime, and a direct WebAssembly path. Rust over Python: distribution to
-authors who are not programmers.
-
-### 4.2 Workspace
-
-```
-crates/
- proofback-model items, rounds, selectors, JSON Schema (serde, schemars)
- proofback-synctex streaming .synctex(.gz) parser and index
- proofback-pdf annotations and positioned text (pdfium adapter behind a trait)
- proofback-tex TeX-aware tokenizer with a source <-> rendered-text offset map
- proofback-anchor matching pipeline and confidence scoring
- proofback-store .proofback/ files, rounds, sync
- proofback-emit list, patch, answered PDF, letter, SARIF, review comments
- proofback-notes free-text notes (v0.5)
- proofback-ai optional model calls for `suggest` and notes (v0.5)
- proofback-docx Word export and import (v0.6)
- proofback-typst Typst projects through the embedded Typst compiler (v0.8)
- proofback-cli clap CLI and ratatui triage
- proofback-mcp MCP server (own JSON-RPC over stdio)
- proofback-wasm wasm-bindgen bindings for browser and npm
- proofback-corpus synthetic corpus, accuracy gates and performance test
-xtask/ schema, fixtures, pinned pdfium, WebAssembly and npm builds
-site/ website and the browser app (/app)
-fixtures/ golden corpus
-integrations/ agent kit and VS Code extension
-npm/ npm package (Node)
-docs/ plan, agent guide, GitHub Action guide
-```
-
-### 4.3 PDF layer (D-05)
-
-Two libraries, each used for what it does best (changed from v1.0, see §21):
-
-- `lopdf` (pure Rust) reads Highlight, Underline, StrikeOut, Squiggly, Text (sticky note), FreeText,
- Caret, Ink, Square, Circle and Line annotations with QuadPoints, Rect, Contents,
- RichContents, author, dates, colour, `/NM` and reply chains (`/IRT`), and writes
- the reply annotations and metadata stripping that `answer` needs;
-- pdfium through `pdfium-render` returns per-character boxes, so the text under a
- highlight is known even when the annotating app did not store it.
-
-What `import` does with each annotation subtype (tested in
-`crates/proofback-cli/tests/e2e.rs`, which also checks that this table and the one in
-`README.md` agree):
-
-| 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 (`Ink`, #23): strokes on one page by one author whose boxes are
-closer than `INK_MERGE_GAP` (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 `INK_MAX_LINES` (6) text
-lines, or sits in the margin with no text beside it. No handwriting recognition and
-no model.
-
-pdfium is Apache-2.0/BSD. Native builds bundle a pinned prebuilt pdfium (checksum
-verified; see §10). The browser loads pdfium's WebAssembly build on demand. Without
-pdfium, import falls back to the text stored in the annotations.
-
-### 4.4 SyncTeX layer (D-06)
-
-Own streaming parser. The format is small and documented, and proofback needs every
-box record on a page (not only the best hit) to score several candidate lines.
-Decompression uses `miniz_oxide` (pure Rust, WebAssembly-friendly). The parsed index
-is cached in `.proofback/cache/` (git-ignored), keyed by file hash.
-
-Paths inside SyncTeX files are normalised (absolute paths, `./` prefixes, Windows
-separators) and must resolve inside the project root.
-
-### 4.5 TeX normaliser (D-07)
-
-`proofback-tex` produces an approximation of the text the PDF shows, with a map from
-every output character back to a source byte range:
-
-- drops comments, most commands and braces; keeps arguments of text commands
- (`\emph{x}` becomes `x`); turns `\cite`, `\ref`, `\label` into placeholders;
-- handles `~`, `\,`, `--`, `---`, TeX quotes, accents, ligatures, `\\`;
-- turns inline math into one placeholder token and marks display math, figures and
- tables as blocks;
-- expands simple parameterless `\newcommand` macros; other macros become opaque tokens;
-- follows `\input`, `\include` and `\subfile`, preferring the file list from SyncTeX.
-
-It is deliberately not a TeX engine. It only has to support fuzzy alignment inside
-the small window SyncTeX has already found.
-
-### 4.6 Source text rules
-
-- Sources are read as UTF-8. Files in another encoding are reported by `doctor` and
- skipped (never written).
-- Line endings are preserved on write (LF or CRLF per file).
-- Canonical positions are UTF-8 byte ranges. Lines are 1-based. Columns are 1-based
- Unicode code points. The MCP server and VS Code extension convert to UTF-16 where
- their protocols need it.
-
-### 4.7 WebAssembly build
-
-`wasm-bindgen` CLI plus `wasm-opt`, driven by a small `xtask` (wasm-pack is
-unmaintained since the rustwasm organisation was archived in 2025). The core runs in
-a Web Worker so the UI never blocks. The build is single-threaded because GitHub
-Pages cannot send the COOP/COEP headers that `SharedArrayBuffer` threads require.
-
----
-
-## 5. Matching pipeline
-
-**Principle: precision before recall (D-14).** A wrong confident anchor costs the
-author more than an honest "page only". Every stage may lower confidence; none may
-invent it.
-
-For each annotation:
-
-1. **Extract** type, page, quads or rect, note text, author, date, colour, `/NM`,
- replies.
-2. **Read the marked text** under the quads plus about 80 characters of context on
- each side, handling hyphenation at line ends and multi-column layouts.
-3. **Coarse locate.** SyncTeX inverse search for each quad (centre and corners) gives
- a ranked set of `(file, line)` candidates. Point annotations use the nearest text
- line on the page.
-4. **Fine locate.** Normalise the candidate lines plus a margin with `proofback-tex`
- and align the marked text with its context (banded Smith-Waterman, bitap for
- short quotes). Map the hit back through the offset map to a source byte range.
-5. **Classify**: `comment`, `question`, `delete`, `insert`, `replace`, `highlight`,
- `figure`, `math`, `general`. StrikeOut with a note becomes `replace` with a
- suggested replacement; Caret with text becomes `insert`; StrikeOut alone becomes
- `delete`.
-6. **Score**: `exact` (character range), `line`, `region` (figure, table, display
- math), or `page` (needs a human). Each level carries a readable reason. An
- alignment with two near-equal hits is never `exact`.
-
-### 5.1 Hard cases designed for from the start
-
-Two-column layouts; hyphenation; ligatures; text produced by macros; `\input` trees;
-floats placed far from their source; captions; footnotes; display math; tables;
-generated text (bibliography, table of contents), flagged `generated` and pointed at
-the `.bib` key or heading where possible; XeLaTeX and LuaLaTeX with non-Latin scripts
-(Greek, Arabic, CJK); and a reviewer who annotated an older draft.
-
-### 5.2 Draft mismatch
-
-Each round records the git commit (when available) 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 ` anchors against
-that commit's files (read through git plumbing, never a shell), then `sync` carries
-the anchors forward to the working tree. With only a PDF, step 4 runs against the
-whole project (text-only mode).
-
-### 5.3 Text-only mode
-
-Without SyncTeX, proofback searches the whole project for the marked text and context,
-using page order as a prior. Confidence is capped at `line` unless the match is
-unique and long. Accuracy is reported separately for this mode.
-
-"Long" is `LONG_MATCH_CHARS` (20) folded characters, counting the marked text plus the
-PDF context on either side that agrees with the source right next to the unique hit
-(`is_long_match` in `proofback-anchor`, boundary tested). A caret without SyncTeX is
-placed after the longest unique text before it, or before the longest unique text
-after it, each at least `LONG_MATCH_CHARS` long; when both are found they must meet.
-The corpus test prints why each text-only item is not exact (repeated text, macro,
-mathematics, hyphenation or ligature, other file, short, other).
-
-### 5.4 Anchors that survive edits
-
-Each item stores W3C Web Annotation style selectors:
-
-- `TextQuoteSelector`: normalised quote, prefix and suffix;
-- `TextPositionSelector`: file, byte range, line and column at the recorded commit;
-- `PdfSelector`: page, quads, PDF hash (provenance only, never used to re-anchor).
-
-`sync` tries quote and context first, then position, and sets the item's
-`anchor.state` to `anchored`, `moved`, `changed` or `lost`.
-
----
-
-## 6. Data model
-
-All state is plain files in the author's project, committed with it (D-08):
-
-```
-.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.
-
-### 6.1 Item
-
-Schema: `https://amet13.github.io/proofback/schema/v1.json`. Every round file names
-it in `$schema` and carries `schema_version`.
-
-```jsonc
-{
- "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 6 to 8 base32 characters of a hash of the round and the
- annotation's identity (`/NM` when present, otherwise page, type and quads).
- Re-importing the same PDF is therefore idempotent and never duplicates items.
-- **Status** (the author's decision): `open`, `done`, `wontfix`, `discuss`,
- `duplicate`. **Anchor state** (proofback's knowledge): separate, see §5.4.
-- **Authors**: stored as written in the PDF. `--anonymize-authors` replaces them with
- `Reviewer 1`, `Reviewer 2` for blind review (see §10).
-
----
-
-## 7. Command reference
-
-| Command | Purpose |
-|---|---|
-| `init` | Create `.proofback/config.toml` and the cache ignore rule |
-| `import ` | Import a PDF (v0.1), notes file (v0.5) or DOCX (v0.6) as a round |
-| `list` | Items as a table, `--json`, or `--md` (GitHub task list); filters by round, status, file, kind |
-| `show ` | One item with source context |
-| `triage` | Terminal UI to confirm, resolve and reply (v0.2) |
-| `resolve ` | Set status and reply |
-| `patch [ids]` | Unified diff for `replace`, `delete`, `insert` items |
-| `apply [ids]` | Write those edits (refuses if the anchored text changed since import) |
-| `sync` | Re-anchor items to the current source |
-| `answer -o ` | Reviewer's PDF with a reply annotation on every note |
-| `letter` | Response letter as LaTeX or Markdown; `--diff-pdf ` names a PDF with the changes highlighted (made by `overfull diff`) |
-| `inline` | Optional `% proofback pb_xxx:` comments or `\todo{}` in the source |
-| `sarif` | SARIF for GitHub code scanning |
-| `stats` | Counts by round, status, file and reviewer |
-| `mcp` | Run the MCP server on stdio (v0.3) |
-| `doctor` | Check SyncTeX presence, encodings and project root |
-| `locate` | Map a PDF position to a source range, without a round (below) |
-
-Global flags: `--json`, `--project `, `--quiet`, `--color auto|always|never`.
-
-**Exit codes** (D-15): `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 (dirty anchor, encoding, path outside project).
-
-**Output schema.** Command JSON (`--json`, MCP results) carries `schema_version` 2
-since items lost their flat location fields and `doctor --json` became an object
-(#25, #26); round files keep their own `schema_version` 1 (§6).
-
-`--json` output is stable within a schema version and documented per command.
-
-The location object, the top-level `--json` fields (`tool`, `version`,
-`schema_version`), the shared exit codes `0` to `2` and the SARIF conventions are
-shared with overfull and specified in [`interop.md`](interop.md) (Interop v1).
-
-**Locator** (#19). `proofback locate --pdf [--synctex ] --page
-[--rect x0,y0,x1,y1] [--text ] [--json]`, or `--stdin` with one JSON query per line
-(`{"page": 3, "rect": [x0, y0, x1, y1], "text": "..."}`), printing one JSON result per
-line. Rectangles are in PDF points, origin bottom-left. A result has `file`, `line`,
-`column`, `end_line`, `end_column` (the units of `Target`), `confidence` and
-`reason`; with confidence `page` it has no source fields. It runs the import pipeline
-(`proofback_anchor::locate`), so confidence follows D-14. Stateless: it reads only
-the sources under `--project` (or the current directory) and never reads or writes
-`.proofback/`. PDF parsing runs in the isolated child process with the usual limits;
-queries are bounded (100,000 per call, 4,096 characters of text, 64 MB of input).
-Queries with `text` work without PDFium; without SyncTeX it searches by text alone.
-Exit codes: `2` for a malformed command line, `3` for an unreadable PDF or SyncTeX
-file or an invalid query line. Same API in WebAssembly (`locate`) and Node
-(`require('proofback').locate`). Schema: `site/schema/locate-v1.json`.
-
----
-
-## 8. AI and agents (D-09)
-
-Principle: **the core is deterministic and offline; AI is a client, not a dependency.**
-
-- **Context for agents.** `show --json` returns the item, the exact source
- range, configurable surrounding lines, the reviewer's quote and the PDF page text.
-- **MCP server** (`proofback mcp`, stdio): `list_items`, `get_item`, `propose_patch`
- (checks the diff applies and touches the anchored range), `apply_patch`,
- `resolve_item`, `sync`, `export`. Targets the current MCP specification; no
- network transport.
-- **Agent kit.** An Agent Skill ("work through review feedback") in the open
- `SKILL.md` format, a Claude Code plugin, an `AGENTS.md` snippet, Cursor rules, and
- `llms.txt` on the website.
-- **Guard rails.**
- - `done` on an edit item (`replace`, `delete`, `insert`) requires the anchored text
- to have changed, unless `--force` is given by a human.
- - `done` on a `comment` or `question` requires a reply.
- - Reviewer text is returned to agents inside a clearly delimited
- `untrusted_reviewer_text` field and documented as data, never instructions
- (prompt-injection defence; see §10).
- - proofback never runs commands and only touches files inside the project root.
-- **Optional suggestions** (v0.5). `proofback suggest ` calls a model the user
- configures (Anthropic, any OpenAI-compatible endpoint, or a local model). Off by
- default. Shows exactly what will be sent before the first call per project. Never
- applies anything automatically.
-- **AI-assisted parsing** only for messy inputs: free-text notes (v0.5) and photos of
- paper pages with handwritten marks (experimental, after v0.8). Handwritten marks
- inside a PDF (`Ink`) need no model: they are anchored by position (§4.3). Results start at `page` confidence
- until the author confirms them.
-
----
-
-## 9. Outputs
-
-| Output | Notes |
-|---|---|
-| Terminal list | Grouped by file; colour only on a TTY |
-| 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 | New file; the original is never modified; status and reply added as replies to each note |
-| Response letter | LaTeX, 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 |
-
----
-
-## 10. Security and privacy (D-16)
-
-proofback reads files written by other people (PDFs, DOCX, notes) and can write to
-the author's source. The threat model:
-
-| Threat | Mitigation |
-|---|---|
-| Malicious PDF exploiting the PDF parser | pdfium is fuzzed upstream and pinned to a recent Chromium branch; proofback updates it on every Chromium security release. In the browser it runs inside the WebAssembly sandbox. Native imports parse the PDF in a child process with memory and time limits. proofback's own parsers are fuzzed with `cargo-fuzz` in CI. |
-| Decompression bombs (`.synctex.gz`, DOCX zip, PDF streams) | Hard limits on decompressed size, entry count, page count and annotation count, all configurable. |
-| XML attacks in DOCX | `quick-xml` with no DTD or external entity resolution. |
-| Path traversal (SyncTeX paths, `\input`, zip entries, `--at` checkouts) | Every path is canonicalised and must stay inside the project root; symlinks leaving the root are refused. |
-| Unwanted writes | Only `apply`, `inline` and `resolve` write. `apply` checks the anchored text is unchanged and never writes outside the root. `--dry-run` everywhere. |
-| Prompt injection through reviewer comments | Reviewer text is marked untrusted in JSON and MCP output; the agent kit tells agents to treat it as data; proofback exposes no tool that runs commands. |
-| Leaking source to an AI provider | `suggest` is off by default, needs per-project consent, shows the payload, and reads API keys from an environment variable named in the config, never from committed files. |
-| Reviewer identity in blind review | `--anonymize-authors` on import; `answer` and `letter` strip PDF metadata (author, creator tool, local paths). |
-| GitHub Action abuse | Runs on `pull_request` with a read-only token by default; posting comments uses a separate `workflow_run` job; all third-party actions pinned by commit SHA; least-privilege `permissions`. |
-| Supply chain | `cargo-deny` (licences, advisories, sources) in CI, Dependabot, release artefacts with SHA-256 checksums and signed build provenance (GitHub attestations), npm provenance, pinned pdfium binaries with checksums. |
-| Website | No third-party requests (fonts self-hosted), Content Security Policy, no cookies or analytics. |
-
-Vulnerabilities are reported privately through GitHub security advisories
-(`SECURITY.md`). No telemetry anywhere in the project.
-
----
-
-## 11. Performance (D-17)
-
-Reference machine: a GitHub-hosted `ubuntu-latest` runner (4 vCPU). Reference input:
-a 300-page thesis, 40 source files, 500 annotations.
-
-| Operation | Budget (native) | Budget (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 |
-
-How:
-
-- SyncTeX is streamed and indexed by page; only pages that carry annotations are
- fully decoded.
-- PDF text is extracted only for annotated pages.
-- Pages are processed in order, in one pass; the budget is met without threads. In
- the browser this runs in a Web Worker.
-- Indexes are cached by content hash in `.proofback/cache/`.
-- pdfium's WebAssembly build is fetched only when a PDF is dropped and then cached.
-- A performance test in CI (`crates/proofback-corpus/tests/perf.rs`) generates the
- reference input and fails when a budget is exceeded.
-
----
-
-## 12. Quality and accuracy (D-10)
-
-- **Golden corpus** in `fixtures/`: 3 pdfLaTeX projects (`article-twocolumn`,
- `thesis-basic`, `thesis-long` with an `\input` tree) and 1 Typst project
- (`typst-paper`), built with `cargo xtask fixtures` (see §21.2). The target remains
- about 15 projects (beamer, maths-heavy, tables and figures, XeLaTeX with Greek and
- Arabic, LuaLaTeX CJK, biblatex, custom macros), built in CI with pinned TeX Live
- images; projects are added as they come.
-- **Synthetic ground truth.** A generator uses SyncTeX forward search to place every
- annotation type on known source ranges and writes it the way Acrobat, Preview,
- Okular, Zotero and PDF Expert do (each has quirks: quad order, missing `/Contents`,
- flattened replies).
-- **Real-world set** in `fixtures/real/`: PDFs annotated in real applications on the
- built fixture PDFs, opt-in, anonymised, under CC BY 4.0, each with a manifest
- (application, version, OS, project, commit) and a ground-truth file. Rules and
- format in `fixtures/real/README.md`; `cargo xtask real-check ` checks a
- donation. The test reports its metrics separately, per application, and gates the
- wrong-anchor rate under 1%; the exact-range gate (90% with SyncTeX) applies from 100
- items. Currently empty: 0 items; v1.0 needs at least 100 items from at least 4 PDF
- applications (§16).
-- **Metrics**, per annotation type, layout and mode:
- - exact-range precision and recall,
- - correct-line rate,
- - wrong-anchor rate (any confident anchor that is wrong),
- - `page` fallback rate.
-- **Release gates**: wrong-anchor rate under 1%; no metric regresses. Results are
- published on the website at every release.
-- Property tests (`proptest`) for the offset map: every normalised character maps
- back inside its source token. Fuzzing for SyncTeX, notes and DOCX parsers.
-
----
-
-## 13. Browser app (v0.4)
-
-- Lives at `/app` on the website. Loads the core in a Web Worker and pdfium on demand.
-- Inputs: annotated PDF, `.synctex.gz`, and sources as a folder
- (``, which every current browser supports) or a zip such as
- Overleaf's download. Overleaf's documentation (checked 2026-12-01) says generated
- files, among them `output.synctex.gz`, are downloaded from Logs and output files,
- Other logs and files; the source zip leaves them out. Not yet tried in the Overleaf
- interface. An import without SyncTeX shows a notice with the text-only rates and
- these instructions.
-- Layout: reviewer's PDF with numbered marks, item list, source with the anchored
- range highlighted. Keyboard first: `j`/`k` move, `d` done, `w` won't fix, `r` reply.
-- Exports: round JSON, patch, Markdown, answered PDF, letter.
-- Offline after first load (service worker). No network requests with user data.
-
----
-
-## 14. Word round trip (v0.6)
-
-Mapping Word edits back is solved at export time:
-
-- `docx export` builds the DOCX with its own writer (no dependencies) or pandoc and
- embeds a hidden bookmark per paragraph carrying the source byte range.
-- `import` reads tracked changes (`w:ins`, `w:del`), comments
- (`comments.xml`, `commentRangeStart`/`End`) and replies straight from the XML, and
- resolves them through the nearest bookmarks and the §5 alignment. DOCX items are
- ordinary items.
-- A DOCX not exported by proofback still works in text-only mode.
-
----
-
-## 15. Website (D-13)
-
-- Static HTML, CSS and a small script; no build step; deployed by GitHub Actions to
- GitHub Pages. The browser app joins under `/app` in v0.4.
-- Visual language taken from the product: PDF-viewer grey, highlighter yellow for
- reviewer marks and the main action, red only for strike-outs, blue for anything
- proofback links. The demo page is set in Libertinus Serif to look like a typeset
- paper. Common AI-generated design defaults are avoided on purpose.
-- Shared design base with overfull (`site/tokens.shared.css`, "shared tokens v1",
- byte-identical in both repositories and loaded before `styles.css`): status colours
- `--ok`, `--warn`, `--error`, `--info`, the focus ring `--focus`, the monospace font
- (Commit Mono) and the document font (Libertinus Serif). proofback keeps the marks of a
- human reviewer (highlighter yellow, strike-out red, viewer grey); overfull keeps the
- marks of a machine check (black slug, rules). Both use one wordmark construction
- (lowercase name, a 0.45em square after a 0.15em gap, on the baseline; yellow here)
- and a footer line: "Before you submit: overfull. After they read it: proofback."
- Editor surfaces, dark in both themes, use the dark values of the shared colours.
- `tools/tokens-check.mjs` pins the file's SHA-256 to its version and checks contrast.
-- Fonts self-hosted and subset (about 140 KB total, under 150 KB, checked in CI). No
- third-party requests.
-- Content Security Policy via ``; the one inline script is allowed by hash.
-- Accessibility: WCAG 2.2 AA contrast in both themes, keyboard-operable demo,
- `aria-pressed` state, live region for the demo output, reduced-motion respected.
-- `llms.txt`, Open Graph image, 404 page.
-- CI checks every pull request: HTML validation and a headless-browser smoke test
- (no console errors, no horizontal overflow at 390 px).
-
----
-
-## 16. Roadmap
-
-| Milestone | Scope | Exit criteria |
-|---|---|---|
-| **M0** ✓ | Repository reset, plan, website, Pages deploy | Site live, plan final |
-| **M1 Foundations** ✓ | Workspace, `model`, `synctex`, `tex` offset map, fixture builder in CI, fuzzing harness | SyncTeX parser fuzzed for 1 CPU-hour without crashes; offset-map property tests green |
-| **M2 = v0.1 Import** ✓ | `pdf`, `anchor`, `init`, `import`, `list`, `show`, `doctor` | Synthetic corpus with SyncTeX: exact-range recall at least 90%, wrong-anchor rate under 1%; performance budgets met |
-| **M3 = v0.2 Close the loop** ✓ | `store`, `triage`, `resolve`, `patch`, `apply`, `sync`, `answer`, `letter`; release pipeline (GitHub Releases, installers, Homebrew formula, build provenance) | A full review round done end to end on a fixture thesis |
-| **M4 = v0.3 Agents and CI** ✓ | MCP server, agent kit, GitHub Action, SARIF | An agent completes a review round on fixtures in an automated eval |
-| **M5 = v0.4 Browser** ✓ | WebAssembly build, `/app`, npm package | Browser results identical to native on the corpus |
-| **M6 = v0.5 Notes** ✓ | Notes parser, optional `suggest` | Notes corpus: wrong-anchor rate under 1% |
-| **M7 = v0.6 Word** ✓ | DOCX export with anchors, DOCX import | Round trip on fixtures: exact-range recall at least 90% |
-| **M8 = v0.7, v0.8** ✓ | VS Code extension, Typst | Same golden suite passes for Typst fixtures |
-| **v1.0** | Accuracy on real-world input, install paths, schema freeze | All of: (1) the real-world corpus has at least 100 items from at least 4 PDF applications, with a wrong-anchor rate under 1%; (2) text-only mode meets its exact-rate gate; (3) schema v1 is frozen; (4) each install path works from GitHub only (release files, installer scripts, Homebrew tap; no other registry); (5) no security advisory is open |
-
-**Scope rule before v1.0 (D-18).** proofback adds no new product surface before v1.0.
-M1 to M8 delivered nine surfaces (CLI, terminal UI, MCP server, agent kit, GitHub
-Action, browser app, Node package, VS Code extension, Typst support). Until v1.0, work
-goes to accuracy, real-world input and install paths. Small additions inside an
-existing surface (a flag, a field, a command that reuses the pipeline) are allowed.
-
----
-
-## 17. Engineering conventions
-
-- Rust 2024 edition, pinned MSRV, `rustfmt`, `clippy -D warnings`.
-- Semantic versioning for the tool; the JSON schema is versioned separately.
-- CI: lint, test, golden accuracy, benchmarks, fuzz smoke run, WebAssembly build,
- site checks, Pages deploy. Every third-party action pinned by commit SHA.
-- Releases are automatic through `.github/workflows/release.yml` (see
- [`docs/releasing.md`](releasing.md)): started from the GitHub website or by merging a
- version bump; every version field must match a dated `CHANGELOG.md` section; GitHub Release with checksums and provenance, shell and
- PowerShell installers, the Node package and the VS Code extension as release files,
- and an optional Homebrew tap. No package registry accounts (npm, Marketplace,
- crates.io) are used: everything installs from GitHub.
-- Changes are recorded in `CHANGELOG.md` under `## Unreleased` as they land.
-- Licence MIT OR Apache-2.0 (D-11). Fixtures CC BY 4.0. Bundled fonts SIL OFL 1.1.
-- Docs are written for people and agents: each command has a runnable example and
- its JSON shape.
-
----
-
-## 18. Risks
-
-| Risk | Mitigation |
-|---|---|
-| pdfium size and build complexity in the browser | On-demand load and caching; the PDF trait keeps a pure-Rust fallback possible |
-| pdfium security updates lag | Track Chromium releases; automated update PR; child-process isolation natively |
-| SyncTeX is line-level and noisy around macros and floats | Text alignment does the fine work; honest confidence; measured on the corpus |
-| PDF apps write annotations inconsistently | Per-app fixtures and a documented quirks table |
-| Draft drift between review and current source | `--at ` plus quote-and-context re-anchoring |
-| Overleaf users without git | Browser app accepts Overleaf zips; state exported as files |
-| Perception as "another AI wrapper" | Deterministic core, published accuracy, AI strictly optional |
-| Scope creep into overfull's area | §1.2 boundary: no document-quality checks |
-| Many surfaces for one maintainer | Scope rule before v1.0 (§16, D-18): no new surface; work goes to accuracy, real-world input and install paths |
-
----
-
-## 19. Audit and grill log
-
-The plan was reviewed for correctness, performance, UX, security, privacy and
-current tooling before being marked final. Each finding and its resolution:
-
-| # | Area | Finding | Resolution |
-|---|---|---|---|
-| 1 | Correctness | Example output used numeric IDs in one place and `pb_` IDs elsewhere | `pb_` IDs everywhere, with unique-prefix matching (§2, §6.1) |
-| 2 | Correctness | Item status mixed the author's decision with anchoring state | Separate `status` and `anchor.state` (§5.4, §6.1) |
-| 3 | Correctness | "`done` requires the text to change" made no sense for questions | Rule applies to edit kinds only; questions need a reply (§8) |
-| 4 | Correctness | Re-importing a PDF could duplicate items | Deterministic IDs from `/NM` or annotation identity (§6.1) |
-| 5 | Correctness | Offsets were undefined for non-ASCII text and editors | UTF-8 byte ranges, code-point columns, UTF-16 at protocol edges (§4.6) |
-| 6 | Correctness | Non-UTF-8 sources and CRLF files could be corrupted by `apply` | Encoding detection, refusal without `--encoding`, line endings preserved (§4.6) |
-| 7 | Correctness | Exit codes claimed to match another project without checking | Own exit codes defined (§7) |
-| 8 | Correctness | Overleaf SyncTeX location stated without verification | Documented from Overleaf's documentation (2026-12-01); the UI step is still to be tried in an account (§13) |
-| 9 | Correctness | Browser app URL pointed at a domain we do not own | Uses the GitHub Pages URL (§2 W6) |
-| 10 | Quality | Accuracy targets measured recall only | Wrong-anchor rate under 1% is a release gate; precision before recall (§5, §12) |
-| 11 | Security | No threat model | Added (§10) |
-| 12 | Security | Untrusted PDFs, archives and XML parsed without limits | Size and count limits, no XML entities, child-process isolation, fuzzing (§10) |
-| 13 | Security | Paths from SyncTeX, `\input` and zips could escape the project | Canonicalised and confined to the root (§4.4, §10) |
-| 14 | Security | Reviewer comments passed to agents could carry prompt injection | Marked untrusted; no command-running tools (§8, §10) |
-| 15 | Security | GitHub Action permissions and action pinning unspecified | Read-only default, `workflow_run` for comments, SHA pinning (§10, §17) |
-| 16 | Security | Supply chain unspecified | cargo-deny, cargo-vet, signed artefacts, provenance, pinned pdfium (§10) |
-| 17 | Privacy | Reviewer names committed to git break blind review | `--anonymize-authors`; metadata stripped from outputs (§6.1, §10) |
-| 18 | Privacy | `suggest` could send source to a provider silently | Off by default, consent, payload preview, keys never committed (§8) |
-| 19 | Privacy | Website loaded fonts from Google and jsDelivr | Fonts self-hosted and subset; CSP added (§15) |
-| 20 | Performance | Budgets had no reference hardware or memory limit | Reference runner, cold and warm budgets, memory caps (§11) |
-| 21 | Performance | Whole-document parsing on every run | Annotated pages only, content-hash cache, parallel pages (§11) |
-| 22 | Performance | Browser threading assumed | Single-threaded worker; GitHub Pages cannot send COOP/COEP (§4.7) |
-| 23 | Modernity | Plan relied on wasm-pack | `wasm-bindgen` CLI and `wasm-opt` via `xtask` (§4.7) |
-| 24 | Modernity | Tool names out of date | `dist` (formerly cargo-dist); Agent Skills format; current MCP spec (§8, §17) |
-| 25 | Modernity | File System Access API is Chromium-only | Fallback to directory input and zip (§13) |
-| 26 | UX | No way to confirm low-confidence items quickly | `triage` terminal UI (§3, §7) |
-| 27 | UX | Command set undocumented | Command reference with flags and exit codes (§7) |
-| 28 | UX | Round files would produce noisy git diffs | Deterministic serialisation (§6) |
-| 29 | Website | Default AI-generated look | Redesigned from the product's own visual language (§15) |
-| 30 | Website | Demo marks hid their text from screen readers; theme toggle had no state | Visible text kept, `aria-pressed` added, live region kept (§15) |
-| 31 | Website | No validation in CI, actions pinned by tag only | HTML validation and browser smoke test on pull requests; SHA-pinned actions (§15) |
-| 32 | Content | Example names were not neutral | Neutral placeholder names (`Prof. Hale`, `Reviewer 1`) |
-
----
-
-## 20. Decision log
-
-| ID | Decision |
-|---|---|
-| D-01 | Independent of overfull; shared conventions only |
-| D-02 | Any reviewed LaTeX document; theses are the flagship story; Typst later |
-| D-03 | Order of surfaces: CLI, then MCP/agents/Action, then browser app, then VS Code |
-| D-04 | One Rust core for native and WebAssembly |
-| D-05 | pdfium (via pdfium-render) for annotations, text boxes and writing replies |
-| D-06 | Own streaming SyncTeX parser |
-| D-07 | TeX normaliser with an offset map, not a TeX engine |
-| D-08 | State in `.proofback/` in the author's repository; no server |
-| D-09 | Deterministic core; AI through MCP and agents; built-in suggestions optional |
-| D-10 | Accuracy measured in CI and published every release |
-| D-11 | MIT OR Apache-2.0 |
-| D-12 | Name **proofback**; free on GitHub, npm and crates.io when checked (2026-11-25) |
-| D-13 | Website visual language taken from the product; static, self-hosted, no third parties |
-| D-14 | Precision before recall; never a confident wrong anchor |
-| D-15 | Exit codes 0 to 4 as in §7 |
-| D-16 | Threat model and mitigations in §10 are requirements, not aspirations |
-| D-17 | Performance budgets in §11 are CI-enforced |
-| D-18 | No new product surface before v1.0; work goes to accuracy, real-world input and install paths (§16) |
-
----
-
-## 21. Implementation notes
-
-Status as of 2026-12-01: M1 to M8 are implemented and tested. 0.3.0 adds the locator,
-handwritten marks, the text-only improvements and output schema 2. v1.0 waits for the
-exit criteria in §16 (real-world corpus, text-only gate, schema freeze, install paths,
-no open advisory).
-
-### 21.1 Measured results
-
-All numbers come from the tests in `crates/proofback-corpus` and the crates' own test
-suites, run in CI on every pull request.
-
-| 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 (ink), with SyncTeX | 66 | never exact by design (line 89.4%, page 10.6%) | 0% | wrong under 1% |
-| Handwritten marks (ink), 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 |
-| Locator against import (markup annotations, both modes) | 300+ | identical | | identical |
-| Browser and npm against native | 40 | identical | | identical |
-| Locator, npm against native | 90 | identical | | identical |
-
-The synthetic generator only marks spans that occur once in the project, so the
-text-only rows are an upper bound: repeated phrases in real reviews stay at `line`
-without SyncTeX. Before the context rule and caret search of §5.3 (2026-12-01) the
-text-only exact rate was 43.3%; 92 of its 127 misses were unique matches shorter than
-20 characters, and 25 were carets, which had no text-only search.
-
-Performance on the reference input (322 pages, 500 notes), CI run of 2026-12-01: cold
-import 245 ms, warm import 28 ms, sync 0.2 ms, 500 cold locator queries 287 ms (budget:
-the cold import's 1 s), peak memory 143 MB. All within §11.
-
-Browser app: the page itself is about 14 KB compressed (plus fonts). The engine is
-fetched when the first import starts and then cached: the core is 670 KB and pdfium
-2419 KB, compressed.
-
-### 21.2 Changes from v1.0 of the plan
-
-| Area | v1.0 said | Implemented | Why |
-|---|---|---|---|
-| MSRV | pinned, unspecified | Rust 1.92 | Required by the embedded Typst compiler |
-| PDF layer | pdfium for everything | `lopdf` for annotations and writing, pdfium for text boxes | Pure-Rust annotation code is easier to fuzz and works without pdfium |
-| MCP | `rmcp` | Own JSON-RPC over stdio (spec 2025-11-25, older versions negotiated) | Small surface, no async runtime, fully tested |
-| Benchmarks | Criterion, fail on 10% regression | Budget test in CI | Shared runners are too noisy for a 10% threshold |
-| Parallelism | `rayon` | Single pass | Budgets met with large margin; same code path as WebAssembly |
-| Releases | `dist` | Own release workflow | Needed custom steps (pdfium, provenance, Homebrew, Node and VS Code packages) |
-| Supply chain | `cargo-vet`, Sigstore | `cargo-deny`, GitHub build attestations | Same guarantees with less maintenance |
-| API keys | environment or OS keychain | environment variable named in config | No native keychain dependency |
-| Encodings | `--encoding` flag | Non-UTF-8 sources skipped and reported | Rare in practice; never writes a file it cannot round-trip |
-| Response letter | LaTeX, Markdown, DOCX | LaTeX, Markdown | Markdown converts to DOCX with pandoc if needed |
-| Word export | make4ht or pandoc | Built-in writer or pandoc | No TeX tool needed at export time |
-| Browser folders | File System Access API with fallback | `webkitdirectory` everywhere, plus zip | One path that works in every browser |
-| Typst | `typst-ide` jump API | Embedded compiler with a glyph to source span index | Character-level precision, no extra dependency |
-| Corpus | about 15 TeX Live projects | 3 pdfLaTeX fixtures plus 1 Typst project with synthetic annotations; the real-world set (`fixtures/real/`) is empty | Grows toward the target in §12 and with donated real-world reviews |
-
-### 21.3 Additional audit findings during implementation
-
-| # | Area | Finding | Resolution |
-|---|---|---|---|
-| 33 | Correctness | Sticky notes anchored to the wrong line | Anchor point is the icon's top-left corner |
-| 34 | Correctness | Items reported `lost` after a replacement edit | Sync moves them to the nearest changed location |
-| 35 | Correctness | TeX normaliser span bugs found by property tests | Fixed; regressions kept in `proptest-regressions` |
-| 36 | Portability | Windows checkouts converted fixture line endings | `.gitattributes` keeps fixtures byte-exact; paragraph splitting accepts CRLF |
-| 37 | Supply chain | `zip` advisories in an older version | Upgraded to `zip` 9.7.3; two Typst-only `quick-xml` advisories ignored with reasons |
-| 38 | Release | The Pages deploy shipped `/app` without its engine, and the browser and npm parity tests did not run on pull requests | The Website workflow builds the engine, runs both parity tests on every pull request and deploys the built engine |
-| 39 | Release | Versions were bumped by hand in six files and only the GitHub Release was automated, while the docs promised npm | `cargo xtask bump` and `release-check`; the workflow verifies the tag and attaches the Node package and VS Code extension to the release; no registry accounts needed |
-| 40 | Website | 19 font sizes, about 50 hard-coded colours, 7 weights, decorative filler | One token set for site and app; filler removed |
-
diff --git a/docs/agents.md b/docs/agents.md
index 315c7ac..ed2153c 100644
--- a/docs/agents.md
+++ b/docs/agents.md
@@ -73,7 +73,7 @@ Cursor (`.cursor/mcp.json`):
[overfull](https://github.com/Amet13/overfull) checks a paper before it is sent;
proofback starts after a reviewer read it. They share conventions, not code:
-proofback never runs overfull (plan §8, decision D-01).
+proofback never runs overfull.
The handoffs:
| Step | What happens |
diff --git a/docs/github-action.md b/docs/github-action.md
index 82dccb9..9e48c42 100644
--- a/docs/github-action.md
+++ b/docs/github-action.md
@@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- - uses: Amet13/proofback@v0.3.0
+ - uses: Amet13/proofback@v1.0.0
with:
pdf: reviews/supervisor-ch3.pdf
synctex: build/main.synctex.gz
@@ -57,7 +57,7 @@ jobs:
name: proofback-review
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
- - uses: Amet13/proofback@v0.3.0
+ - uses: Amet13/proofback@v1.0.0
with:
mode: comment
```
diff --git a/docs/reference.md b/docs/reference.md
new file mode 100644
index 0000000..49d7c76
--- /dev/null
+++ b/docs/reference.md
@@ -0,0 +1,272 @@
+# 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`](stability.md).
+
+## Commands
+
+| Command | Purpose |
+|---|---|
+| `init` | Create `.proofback/config.toml` and the cache ignore rule |
+| `import ` | 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 ` | One item with source context |
+| `triage` | Keyboard UI to confirm, resolve and reply |
+| `resolve ` | Set an item's status and add a reply |
+| `confirm ` | Accept the location of an item an AI model structured |
+| `suggest ` | 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 ` | The reviewer's PDF with a reply on every answered note |
+| `letter` | Response letter as LaTeX or Markdown; `--diff-pdf ` 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 ` 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 `, `--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`](interop.md).
+
+### Locator
+
+```
+proofback locate --pdf [--synctex ] --page [--rect x0,y0,x1,y1] [--text ] [--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`](../site/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 ` 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`](../site/schema/v1.json); every round file names it in
+`$schema`.
+
+```jsonc
+{
+ "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](github-action.md) |
+
+## 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/`](../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/`](../fixtures/real/README.md) collects
+PDFs annotated in real applications and reports its numbers separately, per
+application.
diff --git a/docs/stability.md b/docs/stability.md
new file mode 100644
index 0000000..0f1b210
--- /dev/null
+++ b/docs/stability.md
@@ -0,0 +1,41 @@
+# Stability
+
+From 1.0, proofback follows [Semantic Versioning](https://semver.org/) for the
+interfaces below. A change that breaks one of them needs a new major version; an
+addition (a new command, flag, field or MCP tool) is a minor version. Anything not
+listed here may change in any release.
+
+## What is covered
+
+| Interface | What stays stable | Where it is defined |
+|---|---|---|
+| Command line | Command and flag names and meanings; exit codes `0` success, `1` needs action, `2` usage error, `3` unreadable or invalid input, `4` refused write | `proofback --help`, [`reference.md`](reference.md#commands) |
+| Command JSON (`--json`, MCP results) | Output schema `2`: every object carries `tool`, `version` and `schema_version`; fields are never removed, renamed or given a new meaning; new fields can appear | [`interop.md`](interop.md), [`agents.md`](agents.md) |
+| Round files (`.proofback/rounds/*.json`) | Schema `1`, frozen: every 1.x release reads and writes it unchanged | [`site/schema/v1.json`](../site/schema/v1.json) |
+| Locator | Query and result shapes | [`site/schema/locate-v1.json`](../site/schema/locate-v1.json) |
+| Node package | `load`, `importReview`, `patch`, `exportRound`, `answer`, `resolveItem`, `locate` and their argument and result shapes | [`npm/README.md`](../npm/README.md), `npm/lib/index.d.ts` |
+| MCP server | Tool names (`list_items`, `get_item`, `propose_patch`, `apply_patch`, `resolve_item`, `sync`, `export`) and their arguments | [`agents.md`](agents.md) |
+| Interop with overfull | Interop v1: the location object, shared exit codes, SARIF conventions | [`interop.md`](interop.md) |
+| Release files | `proofback-node.tgz`, `proofback-vscode.vsix`, `install.sh`, `install.ps1`, and one archive per platform | [`releasing.md`](releasing.md) |
+| `.proofback/config.toml` | Existing keys keep their meaning; files written by an older 1.x release still load | [`reference.md`](reference.md#files) |
+
+## What is not covered
+
+- Human-readable output: wording, tables, colours and hints may change.
+- Accuracy: individual results can change as matching improves. The gates in
+ [`reference.md`](reference.md#accuracy) (wrong anchors under 1%,
+ exact-range rates) only get stricter.
+- Rust crates: they are not published and have no stable Rust API.
+- The website, the browser app's layout, and the VS Code extension's interface.
+
+## How breaking changes happen
+
+1. A deprecation is announced in `CHANGELOG.md` at least one minor release before the
+ removal, and the old form keeps working until the next major version.
+2. A new major version lists every break under "Breaking changes" in the changelog.
+3. Round files never change incompatibly within a major version. If a future major
+ version needs a new round-file schema, it reads schema 1 files and converts them.
+
+The two published schema files are pinned by a test
+(`crates/proofback-model/tests/frozen_schemas.rs`): changing either one fails CI
+until the change is reviewed against this page.
diff --git a/fixtures/real/README.md b/fixtures/real/README.md
index 6df6732..a7b9c28 100644
--- a/fixtures/real/README.md
+++ b/fixtures/real/README.md
@@ -87,4 +87,4 @@ PROOFBACK_REQUIRE_PDFIUM=1 cargo test -p proofback-corpus --test accuracy real_w
At least 20 annotations per application, mixing highlights, strike-outs, carets and
sticky notes, on `fixtures/thesis-basic/main.pdf`, from: Adobe Acrobat Reader, macOS
Preview, Zotero, Okular, and one tablet application. v1.0 needs at least 100 items
-from at least 4 applications (`docs/PLAN.md` §16).
+from at least 4 applications before the exact-range gate applies to it.
diff --git a/integrations/claude-code/.claude-plugin/plugin.json b/integrations/claude-code/.claude-plugin/plugin.json
index e7cdfec..2e9abaf 100644
--- a/integrations/claude-code/.claude-plugin/plugin.json
+++ b/integrations/claude-code/.claude-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "proofback",
"description": "Work through reviewer feedback on LaTeX documents: items anchored to exact source ranges, a guarded MCP server, and a review skill.",
- "version": "0.3.0",
+ "version": "1.0.0",
"author": { "name": "proofback contributors" },
"homepage": "https://amet13.github.io/proofback/",
"repository": "https://github.com/Amet13/proofback",
diff --git a/integrations/vscode/package-lock.json b/integrations/vscode/package-lock.json
index 81f6d80..a9f4edc 100644
--- a/integrations/vscode/package-lock.json
+++ b/integrations/vscode/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "proofback",
- "version": "0.3.0",
+ "version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "proofback",
- "version": "0.3.0",
+ "version": "1.0.0",
"license": "MIT OR Apache-2.0",
"devDependencies": {
"@types/node": "26.6.7",
diff --git a/integrations/vscode/package.json b/integrations/vscode/package.json
index 49cf4fc..902e270 100644
--- a/integrations/vscode/package.json
+++ b/integrations/vscode/package.json
@@ -2,7 +2,7 @@
"name": "proofback",
"displayName": "proofback",
"description": "Reviewer feedback from annotated PDFs and Word documents, on the exact lines of your LaTeX source.",
- "version": "0.3.0",
+ "version": "1.0.0",
"publisher": "proofback",
"license": "MIT OR Apache-2.0",
"repository": { "type": "git", "url": "https://github.com/Amet13/proofback.git", "directory": "integrations/vscode" },
diff --git a/npm/package.json b/npm/package.json
index 488136b..1eb89c5 100644
--- a/npm/package.json
+++ b/npm/package.json
@@ -1,6 +1,6 @@
{
"name": "proofback",
- "version": "0.3.0",
+ "version": "1.0.0",
"description": "Map reviewer feedback on a PDF to the exact line of your LaTeX source. WebAssembly build for Node.",
"license": "MIT OR Apache-2.0",
"homepage": "https://amet13.github.io/proofback/",
diff --git a/site/llms.txt b/site/llms.txt
index c64f469..5316d56 100644
--- a/site/llms.txt
+++ b/site/llms.txt
@@ -1,10 +1,11 @@
# proofback
-> proofback maps reviewer feedback on a compiled LaTeX PDF (highlights, strike-outs, carets, notes, email notes, Word tracked changes and comments) to the exact file, line and character range of the LaTeX (or Typst) source. It tracks each item's status and replies across drafts in `.proofback/` inside the author's repository, and exports patches, an answered PDF and a response letter. Deterministic, offline core in Rust (native and WebAssembly). AI agents use it through an MCP server; reviewer text is returned as untrusted data. Interfaces: CLI, MCP server, browser app at /app, Node package and VS Code extension. Release notes: https://github.com/Amet13/proofback/blob/master/CHANGELOG.md
+> proofback maps reviewer feedback on a compiled LaTeX PDF (highlights, strike-outs, carets, notes, email notes, Word tracked changes and comments) to the exact file, line and character range of the LaTeX (or Typst) source. It tracks each item's status and replies across drafts in `.proofback/` inside the author's repository, and exports patches, an answered PDF and a response letter. Deterministic, offline core in Rust (native and WebAssembly). AI agents use it through an MCP server; reviewer text is returned as untrusted data. Interfaces: CLI, MCP server, browser app at /app, Node package and VS Code extension. Release notes: https://github.com/Amet13/proofback/blob/main/CHANGELOG.md
## Docs
-- [Project plan](https://github.com/Amet13/proofback/blob/main/docs/PLAN.md): scope, architecture, matching pipeline, data model, command reference, security, performance, roadmap, decision log
+- [Reference](https://github.com/Amet13/proofback/blob/main/docs/reference.md): commands, exit codes, annotation types, matching pipeline, files, performance, accuracy
+- [Stability](https://github.com/Amet13/proofback/blob/main/docs/stability.md): what stays compatible across 1.x releases
- [Agent guide](https://github.com/Amet13/proofback/blob/main/docs/agents.md): MCP tools, guard rails, JSON output
- [Browser app](https://amet13.github.io/proofback/app/)
- [README](https://github.com/Amet13/proofback/blob/main/README.md)
diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml
index dc8c598..e082c97 100644
--- a/xtask/Cargo.toml
+++ b/xtask/Cargo.toml
@@ -10,10 +10,10 @@ publish.workspace = true
[dependencies]
anyhow = "1.0.105"
-proofback-anchor = { version = "0.3.0", path = "../crates/proofback-anchor" }
-proofback-corpus = { version = "0.3.0", path = "../crates/proofback-corpus" }
-proofback-model = { version = "0.3.0", path = "../crates/proofback-model" }
-proofback-pdf = { version = "0.3.0", path = "../crates/proofback-pdf" }
+proofback-anchor = { version = "1.0.0", path = "../crates/proofback-anchor" }
+proofback-corpus = { version = "1.0.0", path = "../crates/proofback-corpus" }
+proofback-model = { version = "1.0.0", path = "../crates/proofback-model" }
+proofback-pdf = { version = "1.0.0", path = "../crates/proofback-pdf" }
serde_json = "1.0.154"
sha2 = "0.11.0"
From 92837b7844e2b4e7f663a9efba8249dd49d6a2b0 Mon Sep 17 00:00:00 2001
From: Claude
Date: Wed, 2 Dec 2026 00:21:08 +0000
Subject: [PATCH 2/2] xtask pdfium: unpack into an empty directory, archive
outside it
The Windows test job failed with "include/: Refusing to overwrite
archive" when target/pdfium already held an earlier unpack: bsdtar on
Windows mistook the existing files for the archive it was reading, which
sat in the same directory. Download to target/ (as the wasm build
already does) and clear target/pdfium before unpacking.
Co-Authored-By: Claude Opus 5.5
Claude-Session: https://claude.ai/code/session_01Xj9ekYmyESdZUsW8uWkzgv
---
xtask/src/main.rs | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
index 00a42d2..6382b6b 100644
--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -192,8 +192,14 @@ fn pdfium(root: &Path, platform_override: Option<&str>) -> Result<()> {
.find(|(p, _)| *p == platform)
.context("platform not pinned")?;
let dest = root.join("target/pdfium");
+ // Unpack into an empty directory, with the archive outside it: Windows tar can
+ // refuse to overwrite files from an earlier unpack (a restored build cache),
+ // mistaking them for the archive it is reading.
+ if dest.exists() {
+ std::fs::remove_dir_all(&dest)?;
+ }
std::fs::create_dir_all(&dest)?;
- let archive = dest.join(format!("pdfium-{platform}.tgz"));
+ let archive = root.join(format!("target/pdfium-{platform}.tgz"));
let url = format!(
"https://github.com/bblanchon/pdfium-binaries/releases/download/{}/pdfium-{platform}.tgz",
PDFIUM_TAG.replace('/', "%2F")