Repository navigation
feat(engine): link previews phase 1, track B: the head states where each link of the paper lands - #699
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… outside the compile side Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ts ink cannot be told; where each destination lands, by the unit at its point Locate's phases 17 and 18. A float's box on A is the union of the partners of the glyphs, turned glyphs and boxes B shows between its fs<n> and fe<n> points; none where a bracket is missing or unclosed, a piece of its ink has no partner, its ink is on two pages, its caption crosses its bracket, a member of it has ink outside the box, another's glyph meets the box or ink none of its own crosses its edge. Each destination's point lands on the float, display, line at it or first under it in its column; reference entries, headings, notes, displays and boxed floats are covered, anything else is absent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tates its lines; the link phases' time and the destinations for the lab The box's union took a glyph's outline across, which the parts' lines (stated by the advance) passed by a fraction of a point at a justified line's end: the union is now of both. The tally carries the resolved destinations and locate, given a clock, the time of its phases 17 and 18 (the lab's measure). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, the link-targets gate Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…point, a biblatex entry a reference hyperref raises an anchor by the \baselineskip in force over the first baseline of what it marks, into the band of the line above. Landing on the line whose band holds the point took the entry above for 256 citations of 993 over 36 papers (read by the left edge at the destination's x). A destination now lands on a boxed float that holds it, else on a line it stands on (its band and ink hold the point, its baseline at or over it), else on the highest baseline under the point in its column within LAND_BELOW (measured from the baseline; LAND_ABOVE goes). A unit made on A of one biblatex entry (inkreferences) is a reference. FloatBox keeps its union where it is refused, for the lab's look. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and the landings of names no class says Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e or its label, a display's first ink, a float's top hyperref sets an anchor where what it marks begins, raised over it. Over 126 of the 245 papers the first baseline under the point was, for 152 landings, the last line of the entry or note above, standing under the raised point where the raise passes the pitch (1512.03385's bibliography: 0.9 under the point, the entry's label 11.3 under it), read by the left edge at the destination's x. A line that goes on with its member begins nothing, and no point lands on it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… beginning, or nowhere pdfTeX states a destination at the origin of what TeX set next. Where a line, a label or a display under the point within LAND_BELOW begins its ink at the point's x on the format's grid, the first such is what the destination marks: its member where it begins one, nothing where it goes on with its member (an item, a head inside a paragraph's unit), never the beginning under it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tions, the floats' boxes, the landings, the measure The read.ts literal of B1's test goes: the instrument's key is checked over the engine itself (the compile side's bundles hashed, the line's value), which holds read.ts and everything else of the compile side. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…of boxes, no cast of a cast; the memory test counts the new clock reads The census rose for an import cycle (work.ts and floats.ts, targets.ts read each other's types), a duplicated union, a cast of a cast and a length literal: each gone. The prepare reads its clock after A's destinations and locate round its link phases: tests/pdf-reader/prepare-back-memory.test.ts locks B's ink at the clock's eighth read, locate's end, where it locked it at the fourth. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sed for the link targets, with their reason Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
| export function targetsOf(landings: readonly Landing[]): Target[] { | ||
| return [...landings] | ||
| .sort((a, b) => (a.dest < b.dest ? -1 : a.dest > b.dest ? 1 : 0)) | ||
| .filter((l, i, all) => i === 0 || all[i - 1]!.dest !== l.dest) |
There was a problem hiding this comment.
🔴 Long destinations block translation layers
When a PDF destination longer than 2,048 characters lands on a supported target, targetsOf passes it to the head writer. The Target schema rejects it, so the paper loses its entire translation layer instead of one preview.
Learn more
annotationOf serializes internal PDF destinations without a length limit, and the existing LinkTo accepts that string. The new Target limits the same string to 2,048 characters. write validates the entire head before returning its bytes, so a single overlong preview entry prevents the head from being emitted.
Example: A paper links to a 2,047-character named destination stored as a PDF string. Its serialized key includes two quotation marks. If the destination lands on a heading, the 2,049-character key makes head generation fail.
Recommended fix: Share the destination limit between the format and the preview producer. Skip overlong keys before serializing targets, without changing the original link. Add a bundle test that verifies the head still writes and another valid preview survives.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Real: one over-long destination made the whole head fail. Fixed in 9d6629e and 8b163a5: a destination whose key is past the format's bound is left out of targets by the format's own schema and the head is written; that link keeps its jump and gets no preview. Held by packages/engine/tests/head-targets.test.ts and targets.test.ts.
| const first = bracketOf(mem.bFirst) | ||
| if (!first) { | ||
| loose.push(mem) | ||
| continue | ||
| } | ||
| ;(captionsOf.get(first.serial) ?? captionsOf.set(first.serial, []).get(first.serial)!).push(mem.ord) | ||
| if (bracketOf(mem.bLast) !== first) crossing.add(first.serial) |
There was a problem hiding this comment.
🟡 Sideways tables miss link previews
For a fully sideways caption, floatBoxes looks only at level glyphs and treats the caption as unbracketed. The landing pass then excludes the table’s box even when all its ink matches.
Learn more
The marked compile brackets a float with two points that record its position in both the level glyph and painted box streams. place sets bFirst and bLast only from the level glyph list, leaving both unset for a caption made entirely of turned glyphs. The float pass already maps turned glyphs by their painted box positions, but the caption lookup never uses those positions. The landing pass requires a caption ordinal to expose a float preview.
Example: A paper uses sidewaystable with a caption and a reference to the table. All the sideways ink pairs, but the caption has no level glyphs and the resulting float box has no caption ordinal.
Recommended fix: Include the caption’s owned turned glyphs on B in bracket lookup and crossing checks, using each glyph’s box position. Test a bracketed sideways table with a fully turned caption and a destination that lands on it.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Declined for this pull request, and recorded. The reading is right: a caption set wholly turned is read as outside its bracket, so that float is stated without a box. The effect is a preview that is not offered (the link keeps its jump), never a wrong one, and that is the rule this change holds: a box is stated only where every piece of its ink can be told. Reading turned glyphs into a bracket is a change of its own with its own measure over the corpus.
| // (that column's first line of text: the highest of the members' lines there) | ||
| let first: Member['lines'][number] | null = null | ||
| for (const m of members) | ||
| for (const l of m.lines) | ||
| if (l[0] === np && l[7] < col[1] && l[8] > col[0] && (!first || l[5] > first[5])) first = l |
There was a problem hiding this comment.
🟡 Heading previews continue at running headers
When a heading preview spills onto the next page, headingOf picks the highest overlapping line, including running headers. The continuation starts above the body and cuts off part of the intended text.
Learn more
A heading preview has a fixed height. When the current column cannot fit it, the continuation spends the remaining height from the next column’s first text line. The engine represents running headers and footers as members too (HEAD_FOOT), and columnsAndMeasures gives members’ lines measures that can overlap the next column. Since the scan chooses the highest overlapping line with no body-text check, a running header can win.
Example: A heading leaves 90 points for the next page. Its first body line tops out at y=700 and the running header at y=745. The continuation crops y=655–745 instead of y=610–700, omitting the last 45 points of the intended body area.
Recommended fix: Choose the next column’s first body-text line rather than the highest overlapping member. Use the destination column for the continuation width and add a regression case with a running header above the next page’s first paragraph.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Real. Fixed in 9d6629e: a heading's continuation on the next page starts at the column's body, not at a running head. Held by packages/engine/tests/targets.test.ts.
| for (const f of readdirSync(dir).filter((x) => x.endsWith('.json')).sort()) { | ||
| const d = JSON.parse(readFileSync(join(dir, f), 'utf8')) | ||
| if (!d.linkTargets) continue | ||
| records.push([d.id, d.linkTargets]) |
There was a problem hiding this comment.
Real: a run over dumps made before this change checked nothing and passed. Fixed in 126cc69: the gate fails where no paper states a record (tests/lab/floats-gate.test.ts, "fails where no paper states a record").
| for (const [, el] of mem.elements) { | ||
| if (el.kind !== 'display') continue | ||
| let box: Box4 | null = null | ||
| for (const k of el.ink) if (k[0] === page) box = grow(box, [k[1], k[2], k[3], k[4]]) |
There was a problem hiding this comment.
🔍 Display previews exclude kept equations
targetsOf only recognizes display elements. The engine also stores equations outside paragraph units as kept display blocks, which never become display targets.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Declined for this pull request, and recorded. True: an equation kept as its own block is not a display element, so a destination on it lands nowhere. The effect is a preview that is not offered (the link keeps its jump), never a wrong one. Stating it means a second source of display targets with its own evidence and its own check, which is a change of its own.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c791218723
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const ls = mem.lines.filter((l) => l[0] === page) | ||
| const x0 = Math.min(box[0], ...ls.map((l) => l[7])) | ||
| const x1 = Math.max(box[2], ...ls.map((l) => l[8])) |
There was a problem hiding this comment.
Restrict each display's measure to its own column
When a paragraph continues across both columns on the same page, this collects measures from both columns, making every display in that paragraph eligible for destinations in either column through itemAt's inColumn predicate. A probe with columns [72,300] and [312,540], a left-column display at baseline 607, and a destination at (312,625) incorrectly emits that left-column display as the target despite there being no nearby right-column beginning. This writes an unrelated equation into the head's preview metadata. Derive the display's measure from lines in its own column rather than all of the member's lines on the page.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Real: a display took the measures of every column its paragraph ran through. Fixed in 9d6629e: a display is measured in its own column, so a point in the other column no longer lands on it. The probe of this thread is a test in packages/engine/tests/targets.test.ts (red before the fix).
| .filter((l, i, all) => i === 0 || all[i - 1]!.dest !== l.dest) | ||
| .map( | ||
| (l): Target => | ||
| l.next ? [l.dest, l.kind, l.page, l.ord, l.box, l.next[0], l.next[1]] : [l.dest, l.kind, l.page, l.ord, l.box], |
There was a problem hiding this comment.
Omit overlong destination keys before writing the head
When a resolved destination's JSON-encoded key exceeds 2,048 characters and lands on a covered target, this copies it into the head without enforcing Target's new string limit. Existing LinkTo.dest accepts such keys without a length restriction, and neither destination resolution nor landing filters them out. Consequently, write('head', head) throws a FormatError and aborts preparation of an otherwise supported paper solely because optional preview metadata was added. A probe through both target builders reproduces this failure while the same head without targets writes successfully. Skip overlong preview destinations here so their links retain the existing jump behavior.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
…left out of the head, a display in its own column, a heading's run-on from the column's body - A destination longer than format's TARGET_DEST_MAX (2,048) landing anywhere made the head's schema refuse the whole head: it is left out, its links keeping their jump (red: head-targets). - A display took the measure of every line of its paragraph on the page, both columns where the paragraph goes on in the other: a point in that column landed on it. Its measure is its own column's (red: targets). - A heading's window running on to the next page began at that page's highest line, a running head over the body: it begins at the first line inside a column's body as TeX's page builder broke it (bracketsOf's bs/be; red: targets). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rules gate: passedModel tier of the layer gate on 32 outputs of 7 targets, The rule set changes no target. No output for zh-TW, pt, it, nl, pl, tr, id, ms, cs, sv, uk, bg: their rules are not measured here. de: 5 outputs, no measure moved
es: 4 outputs, no measure moved
fr: 4 outputs, no measure moved
ja: 4 outputs, no measure moved
ko: 4 outputs, no measure moved
ru: 4 outputs, no measure moved
zh: 7 outputs, no measure moved
The links open the lab on a machine that has the fixtures. No page and no text of a paper is shown here: the papers are under arXiv's licence. |
…at its head Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…at's own schema; a test's callback returns nothing The census counted the named bound as a budget of its own: the head's writer now keeps the targets format's Target reads, its bound stated once, where it was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… with its reason Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
… point in the gutter is the right column's The lead's ruling of 2026-11-27: a link's target is what a reader is shown on hover, and a landing the engine's own evidence contradicts is never stated. - A destination point in the gutter between two columns belongs to the column on its right: TeX sets an anchor at or left of where its text begins (a label wider than its box carries it out left of its column), and no text of the left column begins in the gutter. - A page anchor (hyperref's page.<n>) is a page, no thing on it: never stated. - The left edge at the point (the line, label or display whose ink begins at the destination's x on the format's grid, its baseline the first under the point) naming another member refuses the landing. - A name of the simple shape claims a kind by the scheme of the package that makes it (cite.<key>, Hfootnote.<n>, a counter of LaTeX's kernel and its hyperref value): a claim of another kind refuses it. A name that claims nothing (an item, a package's or the paper's counter, a compound name) is stated only where the edge confirms the member. Each refusal is kept for the lab (Located.refusedTargets), never stated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ce contradicts or does not prove Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gin, unraised Over the 245, 42 citations of 9 papers were refused as contradicted: each anchor stood at its entry's label's left edge and on its baseline (unraised), which the rule lands right, and the edge reading, taking only baselines under the point, named the next entry 8 under it. A line, label or display whose ink begins at the point's x and whose baseline is the point's own is the edge reading's first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…grid pdfTeX states a destination unrounded (314.9697) where the parts state the ink it stands at on the grid (314.97): compared raw, a point at an entry's label's left edge fell a fraction outside it, and the entry under it was landed, which the edge reading then refused (15 citations of the 245). The point's height and x and the ink's band and edges are compared on the grid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e gutter, the gate on landings and the measure Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… alone, with its reason Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
What
Link previews, phase 1, track B (the engine): the prepare states, once a paper, where each destination of the paper's links lands, so that the reader (PR-2) can preview it from the head alone.
docs/PDF-READER.md§20 is the whole account.packages/format:TargetKind,Target,Head.targets(optional: a reader of before strips it,FORMATstays 1).locate/dests.ts: every destination of A's link annotations resolved on A (its page and the point its fit names), through A's own document opened once for this alone; outsideread.tsand the compile side.locate/floats.ts(locate's phase 17): each float's box from thefs<n>/fe<n>brackets the marked compile already makes, the union of the alignment's partners of the glyphs, turned glyphs and boxes between them; no box, with its cause, on any doubt (unbracketed,unclosed,unpaired,pages,empty,caption,outside,foreign,cut). No threshold: each count must be 0.locate/targets.ts(phase 18): a destination lands on a boxed float that holds its point, a beginning it stands on, the line/label/display whose ink begins at its x under it, else the first beginning under it in its column withinLAND_BELOW; references (a\bibitementry or a biblatex entry made on A), headings (a window of 0.19 of the page, running on to the next column), notes, displays and boxed floats are covered; anything else is absent and keeps its jump.bundle/bundle.ts: the head'stargets, sorted, written only where non-empty.lab/pdf/prepare-back/link-targets.mjs(the record in run.mjs's located dump),floats-gate.mjs(the gate),link-targetsin the release check's full tier.What moved, and what did not
targets.FORMAT,PIPELINE_VERSION,TRANSLATE_VERSION,LAYOUT, unit ids, rows: none moves. The prepare build moves (a new head for every paper prepared again).The measure (§20.5)
The lead's ruling on landings (after the review round)
A landing the engine's own evidence contradicts is never stated (
docs/PDF-READER.md§20.3, §20.5). Two readings that are not the rule judge each landing: the left edge at the destination's point (pdfTeX states a destination at the origin of what TeX sets next) and the name's claim, read as a format by the scheme of the package that makes it (cite.,Hfootnote.,page., a counter of LaTeX's kernel). A page anchor, a landing the edge contradicts, one whose name claims another kind, and one whose name claims nothing with no edge to confirm it are not stated. A point in the gutter belongs to the column on its right; a point on a line's ink is compared on the format's grid. The gate fails on any stated landing wrong. Over the 245: 15,548 stated (8,550 proved by the edge, 6,998 their kind claimed by their name alone), 108 refused, 0 wrong; every object but the heads byte for byte the line's.Review round (Codex, Devin)
Adopted, each with a red test first: a destination the format's
Targetrefuses (past 2,048 characters) is left out of the head rather than refusing it (head-targets); a display's measure is its own column's (targets); a heading's run-on starts at the first line of a column's body, never a running head (targets); the gate fails where no paper states a record (floats-gate). Declined, as missed previews and never wrong ones (stated in §20.5): a caption set wholly turned stays unbracketed; a display kept as a block of its own is no display target.Tests
packages/format/tests/format.test.ts(targets read, stripped, refused),packages/engine/tests/dests.test.ts,floats.test.ts,targets.test.ts,head-targets.test.ts,tests/lab/floats-gate.test.ts.🤖 Generated with Claude Code