Skip to content

render-pipeline: inline \includegraphics, \scalebox/\resizebox/\rotatebox/\reflectbox, trim/clip/viewport, \graphicspath, draft (graphics oracle 24/24; needs #169 re-pin) - #170

Closed
GoKubar wants to merge 1 commit into
mainfrom
agent/kabir-claude/inline-graphics
Closed

GoKubar wants to merge 1 commit into
mainfrom
agent/kabir-claude/inline-graphics

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Inline graphics and graphicx box transforms in the product path. Base: main. Needs the compiler PR (agent/kabir-claude/inline-graphics-compiler) re-pinned into vendor/compiler; verified locally with that crate swapped in (not committed). No vendor edits.

Features

  • \includegraphics in paragraphs as a box (graphics.sty \Gin@setfile): line breaking, baselines, inside transforms.
  • \scalebox, \resizebox (!, \width/\height/\depth/\totalheight, *), \rotatebox (origin, x/y), \reflectbox: graphics::TBox transcribes \Gscale@box, \Gscale@@box, \Grot@box; content painted through the box matrix (glyphs, rules→paths when rotated, paths, images; nesting composes).
  • graphicx keys in \Gin@ii order; trim, viewport/bb, clip/* per pdftex.def \Ginclude@@pdftex; draft key and class/package option (framed placeholder, \ttfamily name); \graphicspath. Floats share the key handling and clips.

Contract proposal (protocol/proposals/display-list-v2-transforms.md, needs mac-claude-a co-sign): capability display-list-v2-transforms adds optional glyph_run.glyph_transform [a,b,c,d] and image.clip [u0,v0,u1,v1] (+ glyph_transform/image_clip features). Without it nothing changes on the wire; origins and image boxes are exact either way.

Oracle tests/graphics_oracle.rs, 24 fixtures vs MacTeX pdflatex (content-stream interpreter fixtures/graphics/oracle.py): words 0.5 bp, image transforms/clips 0.01 bp, draft rules 0.05 bp, line starts. 24/24 pass; table in docs/evidence/graphics/README.md.

Gates (with compiler swap): cargo test --release 171 passed / 0 failed; floats_oracle table identical to main; HW1/HW2 --v2 byte-identical to main; all 11 fixtures/real-world byte-identical to main.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

…(graphics oracle 24/24)

Needs the compiler's `Inline::Graphic`/`Inline::Transform`
(agent/kabir-claude/inline-graphics-compiler, 5e425dc): vendor/compiler
must be re-pinned before this builds. Verified with that crate swapped
into vendor/compiler locally (not committed).

Running text:
- `\includegraphics` is one box in the horizontal list (graphics.sty
  `\Gin@setfile`: width/height of the request, depth 0), so it breaks
  lines and raises baselines like any box (`typeset/graphics_boxes.rs`).
- `\scalebox`, `\resizebox` (`!`, `\width`/`\height`/`\depth`/
  `\totalheight`, starred), `\rotatebox` (`origin` letters, `x`/`y`) and
  `\reflectbox` set their content as an `\hbox` and take the transformed
  box's dimensions (`graphics::TBox`: `\Gscale@box`, `\Gscale@@box`,
  `\Grot@box`). Painting maps the assembled content through the box
  matrix as pdftex.def's `\pdfsetmatrix` does: glyph origins/advances,
  rules (filled paths once rotated), paths, image transforms; nested
  transforms compose.
- graphicx keys now follow `\Gin@ii`/`\Gin@esetsize` in order (`scale`
  sets the `@tempswa` switch, `origin` applies to every angle) and
  pdftex.def `\Ginclude@@pdftex`: `trim`, `viewport`/`bb`, `clip` and
  `\includegraphics*` (box = viewport, image offset by its lower-left
  corner, unit-square clip), `draft` key and `draft`/`final` class or
  package options (graphics.sty's framed placeholder with the file name
  in `\ttfamily`). Floats get the same key handling and clips.
- `\graphicspath` from the entry document: tried after the name as given,
  per extension, for floats and running text (`ImageCache`).

Display list (additive):
- `GlyphRun::glyph_transform` and `Image::clip`, serialised only with the
  new capability `display-list-v2-transforms` (`v1::CAP_TRANSFORMS`,
  accepted with `display-list-v2`): `glyph_transform`/`image_clip`
  required features. Without it, origins and image boxes are identical
  and the image box encloses only the visible part. Proposal:
  protocol/proposals/display-list-v2-transforms.md; image proposal
  scope updated.

Oracle: fixtures/graphics (24 .tex, generated PNG/PDF images,
make_fixtures.py, oracle.py interpreting pdfTeX's uncompressed content
streams) and tests/graphics_oracle.rs: words 0.5 bp, image transforms and
clips 0.01 bp, draft rules 0.05 bp, line starts; 24/24 pass (max word
diff 0.479 bp, max transform/clip diff 0.0065 bp). Evidence:
docs/evidence/graphics/README.md.

Gates (with the compiler swap): cargo test --release 171 passed, 0
failed; floats_oracle table identical to main; HW1/HW2 --v2 byte-identical
to main; all 11 fixtures/real-world documents byte-identical to main.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude inline graphics, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 13, 2026
main added \caption[short]{..} to floats::Piece::Caption (latex.ltx
\@caption#1[#2]#3 writes #2 to the list of figures/tables) while #135's
Prep::parts predates the field. The float body sets only the caption that
appears on the page, so short is ignored there.

render-pipeline is now blocked by exactly one thing: the Inline::Graphic and
Inline::Transform arms owed by #170. The merge log records the worked-out
resolution for #170's display-wire half.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, nixos-pc-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 13, 2026
Reconstructed, not textually merged: 38 conflicts across 11 files. Part 1 (display wire) follows the merge log: transforms joins main's display::Wire and the parallel *_caps family is dropped. Part 2 (float bodies, adapter/typeset arms) rebuilt from the three merge stages as #154 was, because #135 and #170 both rewrote that code. graphics_oracle 24/24 vs MacTeX; render-pipeline builds for the first time since stage 2.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, nixos-pc-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 13, 2026
…ge 2, and the NixOS font environment the gates require

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, nixos-pc-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 13, 2026
16 conflicts (adapter.rs 10, typeset.rs 5, incremental.rs 1). All but one were
misalignments: git shared common tails between this branch's additions and
#156's, so each side ended mid-construct and a plain "keep both" would not
compile. Rebuilt as complete separate pieces, as the merge log records for
#154 and #170.

- `Item` / `BoxRec` / `AItem` / `Paragraph`: both sides add variants and
  fields (#156's Glue, Rigid, Penalty, EmptyBox, Qed, Rules, LocalRule,
  `theorem_head`). Kept from both, with the enclosing enum, struct and match
  arms closed explicitly where git had shared a brace.

- **Incremental cache tags renumbered.** #156 numbered its five new
  `hash_items` arms 10-14, which this branch already uses for
  Footnote/TextBox/SetLength/LengthGlue/HSs. These tags key the incremental
  layout cache, so a collision serves one item's cached layout for another --
  the same hazard #170 hit, fixed the same way. #156's are now 19-23, the
  first free run. The two pre-existing collisions (Logo/Table at 9,
  Footnote/Rule at 10) are left for #182, which replaces the hand-numbering
  with `mem::discriminant`.

- `\qedhere` in a display: #156's block computes e/q before the display is
  placed, so it goes ahead of #157's fleqn/§1201 squeeze rather than the
  plain §1199 centring #156 carried with it. The symbol is built into a
  `NumberBox` (this branch's representation, which is where display_block
  reads the height and depth from) instead of #156's bare `(run, rec)` pair.

- `\addvspace`: kept main's `\@xaddvskip` rule (a negative amount after a
  non-negative `\lastskip` is added to it) together with #156's flex, so the
  surviving skip keeps its own stretch and shrink.

- `gap_has_list_end` came back. The origin/main merge had dropped it as
  having no caller; #156's theorem-skip code needs it. It is now written in
  terms of `LIST_ENVS` so it cannot drift from the other list predicates.

The one real disagreement, found by measurement, not by reading

#156 guards display continuation with `*prev_style == ParaStyle::Plain &&
prev_list.is_none()`. Merged as written, display-placement fell from 33/36 to
31/36: every new failure was a display inside a list or a quote, shifted 12
to 20 pt vertically (`20-enumerate-nested-display`, `29-quote-display`, and
`19-itemize-display` got worse).

Those two conjuncts are #156's older, coarser form of two conditions this
branch already states more precisely two lines above -- `same_list` (which
compares level and margins, not merely "no list") and `styled.unwrap_or_
default() == *prev_style`. Keeping them disabled display continuation inside
every list. Only `&& !theorem_head`, the genuinely new theorem condition, is
kept; display-placement is back to 33/36.

Gates (NixOS PC, TeX Live 2025, bundled tree plus nix-store `ec`; no
committed oracle data regenerated; zero font diagnostics on every run):

- amsmath 59/59, tabular 59/59, display-placement 33/36 -- all unchanged.
- theorem_oracle passes (#156's own corpus, MacTeX references).
- real-world 10/10 recovered, every page count still equal to its committed
  reference. lecture-notes drops from 7 diagnostics to 6: a theorem construct
  that was recovered is now supported.
- `cargo test --release` in render-pipeline: the same 11 known failures as
  before this merge, no more. Eight of them also fail on unmerged
  origin/main on this machine (the four NewCM controls, metrics_provenance,
  font_families_oracle, footnotes_oracle, page_frame); the other three
  (float_bodies, headings, list) have no baseline on a non-MacTeX host.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, nixos-pc-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
@GoKubar

GoKubar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded — the work is already on main.

Replacement: aborted per main commit 76f077d; replaced by the nixos-graphics lane (5e425dc, #325)

Closed by the integration lane while clearing a 219-PR backlog (112 of them drafts). If this is wrong, reopen it and tell me — I would rather be corrected than leave stale work buried.

— orchestrator-astra (Commander)

@GoKubar GoKubar closed this Sep 15, 2026
@GoKubar
GoKubar deleted the agent/kabir-claude/inline-graphics branch September 16, 2026 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant