Skip to content

\leftskip/\rightskip are the background, glue orders are carried, and the wide-open pass is gone - #780

Merged
tannevaled merged 2 commits into
mainfrom
ragged-background
Nov 14, 2026
Merged

tannevaled merged 2 commits into
mainfrom
ragged-background

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

go-typeset/linebreak v1.5.0 implements tex.web §16307-16315 and §16790-16793, so the three things this engine did instead can all go — and #768's second finding closes with them.

What goes

(1) The fil is carried, not flattened. toItems read if c.spec.stretchOrder > 0 { st = 1e6 }, making plus 1fil a large finite stretch. §16790-16793 gives any line carrying fil/fill/filll badness 0 and fitness decent — perfect, not merely very good.

(2) The skips are the background. They were added to each line after breaking, so the breaker never saw them: it broke the paragraph justified and the ragged glue was painted on afterwards. skipBackground() hands them over as §16307-16315 seeds active_width — width, stretch by order, shrink.

(3) The wide-open pass is gone — #768's finding (2). A pass at \tolerance=maxBadRatio has no counterpart in tex.web; §863 has three passes and none raises the tolerance. It survived #778's removal attempt because four tests then stopped hyphenating words that must be hyphenated: \raggedright lines TeX scores at badness 0 were infeasible here, so our pass 2 had no solution where TeX's had one. (1) and (2) remove that cause. The first pass's hand-opened tolerance goes with it.

Measured — #768's witness

\hsize=45pt, \fussy, face and \tolerance verified identical:

reference  Typographical / incomprehen- / sibilities over- / whelm ev- / ery paragraph.
here       Typographical / incomprehen- / sibilities over- / whelm every / paragraph.

Five lines against the reference's five, lines 1–3 matching to 0.02pt. Before: seven. The residue is ev-ery, a hyphenation point the reference takes on the same patterns and we do not.

Measured — the corpus, and it does not say "better"

gotex-refdiff -layout, 60 sampled at seed 1, 40 scored both sides:

base head
mean line agreement 91.23% 91.34% +0.11 pt, better
page count exactly the reference's 12/40 13/40 +1, better
Σ|page error| 123 125 +2, worse
mean divergence 3.884 3.935 +0.051, worse

35 of 40 moved. One status flip in our favour: 2607.28976 MISSING → ok — a paper that did not render now renders, at 26 pages against a reference of 26.

⚠ The tally and the error disagree, so both are above. Three papers moved one page; two are missing pages (−3, −2), which is #381 — our lines hold more than the reference's — exposed a little further now that lines are not padded out with extra hyphens. The third is PAGE OVERFLOW (+7) on a class whose line agreement is 75%.

⚠ Not claimed: that the corpus got better. On the aggregates it did not. What it got is faithful: two workarounds removed and one sentence of tex.web applied where three special cases stood.

⚠ Load was 5–10. Geometry and counts are exact under load; what load threatens is which papers get scored, and the sets differ only by 2607.11306, whose reference extraction failed — in both directions across four runs today, so it is the harness's flake and not ours.

Three defects found on the way, all one mistake

A ratio read without its order. Line.Ratio is measured against the highest order on the line, so an ordinary last line with \parfillskip = 0pt plus 1fil reports a ratio near 300:

  • hasBadLine called every paragraph bad, so the first pass failed on all of them and every document went to the hyphenating pass;
  • the underfull counter reported an underfull line on an ordinary paragraph;
  • the text layer discarded inter-word glue arriving while its run was empty — the case after a formula, where the math closes the run before the glue arrives. $E = mc^2$ exactly came out mc^2exactly.

The third only showed once the spacing was right: the reference ends that witness line at x1=408.21, we now end at 406.91, where we used to end at 477.50 — almost 70pt wide. The layer's gap threshold had been calibrated against our own loose spacing, so the exact signal is used rather than the bar widened.

Two fixtures asserted what the reference does not do

Both re-checked against fresh tectonic runs rather than against the note written in the test:

  • \hyphenation{photo-graphy}: at \hsize=58pt the reference leaves photography whole (A photography / and a manu- / script and a bib- / liography fol- / low here.), so asserting photo- there was asserting our own old output. At 40pt it does break photo-graphy, and that is the fixture now; the "a word with no entry still gets the patterns" half moved to its own test with its own measure.
  • TestHyphenationInsertsHyphen: at spMock's widths the best hyphenated first line is 28pt on a 32pt measure with 1.5pt of stretch — a badness near 1900, so nothing hyphenated is feasible at \tolerance=200 and one overfull line is the right answer. The fixture now states a tolerance in which its own subject can happen.

Refs #768, #381, #778, go-typeset/linebreak#12.

(#778 is merged and cited for the removal attempt it records; #768's first finding — \sloppy — and #381 stay open.)

🤖 Generated with Claude Code

tannevaled and others added 2 commits November 14, 2026 18:50
… the wide-open pass is gone

go-typeset/linebreak v1.5.0 implements tex.web §16307-16315 and §16790-16793, so
the three things this engine did instead can all go.

⛔ (1) THE FIL IS CARRIED, NOT FLATTENED. toItems read

	if c.spec.stretchOrder > 0 { st = 1e6 }

which made `plus 1fil` a large FINITE stretch. §16790-16793 gives any line
carrying fil/fill/filll badness 0 and fitness `decent` — perfect, not merely very
good — so a flattened fil came out with a large but finite badness.

⛔ (2) THE SKIPS ARE THE BACKGROUND. They were added to each line AFTER breaking,
so the breaker never saw them: it broke the paragraph justified and the ragged
glue was painted on afterwards. skipBackground() now hands them to the breaker as
§16307-16315 seeds active_width with them, width and stretch-by-order and shrink.

⛔ (3) AND THE WIDE-OPEN PASS IS GONE — #768's finding (2). A pass at
\tolerance=maxBadRatio has no counterpart in tex.web; §863 has three passes and
none of them raises the tolerance. It survived #778's removal attempt because
four tests then stopped hyphenating words that must be hyphenated: \raggedright
lines TeX scores at badness 0 were infeasible here, so our pass 2 had no solution
where TeX's had one. (1) and (2) remove that cause, and the first pass's
hand-opened tolerance goes with it.

## Measured

#768's witness (\hsize=45pt, \fussy), face and \tolerance verified identical:

	reference  Typographical / incomprehen- / sibilities over- / whelm ev- / ery paragraph.
	here       Typographical / incomprehen- / sibilities over- / whelm every / paragraph.

FIVE lines against the reference's five, lines 1-3 matching to 0.02pt. Before:
seven. The residue is `ev-ery`, a hyphenation point we take and the reference
does not on the same patterns.

Corpus, gotex-refdiff -layout, 60 sampled seed 1, 40 scored both sides, load 5-10
(geometry and counts are exact under load; what load threatens is which papers
get scored, and the sets differ only by a reference extraction that failed on one
run — 2607.11306, flaky in both directions across four runs today):

	mean line agreement   91.23% -> 91.34%   +0.11 pt   better
	page count exact        12/40 -> 13/40        +1     better
	Σ|page error|             123 -> 125          +2     WORSE
	mean divergence         3.884 -> 3.935     +0.051    WORSE
	moved 35 of 40; one status flip, 2607.28976 MISSING -> ok (and 25 -> 26
	pages against a reference of 26: a paper that did not render now renders
	exactly right)

⚠ THE TALLY AND THE ERROR DISAGREE, so both are here. Three papers moved one page
and two of them are MISSING PAGES (-3 and -2): we fit MORE per page than the
reference, which is #381's standing finding and is exposed slightly further now
that we no longer pad lines out with extra hyphens. The third is PAGE OVERFLOW
(+7) on a class whose line agreement is 75%.

⚠ NOT CLAIMED: that the corpus got better. On the aggregates it did not. What it
got is faithful — two workarounds removed and one sentence of tex.web applied
where three special cases stood.

## Three defects found on the way, all one mistake

A ratio read without its order. Line.Ratio is measured against the HIGHEST order
on the line, so an ordinary last line with \parfillskip = 0pt plus 1fil reports a
ratio near 300:

  - hasBadLine called EVERY paragraph bad, so the first pass failed on all of
    them and every document went to the hyphenating pass;
  - the underfull counter reported an underfull line on an ordinary paragraph;
  - and the text layer DISCARDED inter-word glue arriving while its run was
    empty — the case after a formula, where the math closes the run before the
    glue arrives. `$E = mc^2$ exactly` came out `mc^2exactly`.

The third only showed once the spacing was RIGHT: the reference ends that witness
line at x1=408.21 and we now end at 406.91, where we used to end at 477.50 —
almost 70pt wide. The layer's gap threshold had been calibrated against our own
loose spacing, so the exact signal is used instead of widening the bar.

## Two fixtures asserted what the reference does not do

Both re-checked against fresh tectonic runs rather than against the note in the
test:

  - \hyphenation{photo-graphy}: at \hsize=58pt the reference leaves
    `photography` WHOLE (`A photography / and a manu- / script and a bib- /
    liography fol- / low here.`), so asserting `photo-` there was asserting our
    own old output. At 40pt it does break `photo-graphy`, and that is the fixture
    now; the pattern half moved to its own test with its own measure.
  - TestHyphenationInsertsHyphen: at spMock's widths the best hyphenated first
    line is 28pt on a 32pt measure with 1.5pt of stretch — badness near 1900, so
    NOTHING hyphenated is feasible at \tolerance=200 and one overfull line is the
    right answer. The fixture now states a tolerance in which its own subject can
    happen.

Refs #768, #381, go-typeset/linebreak#12.

Co-Authored-By: Claude Opus 5 <[email protected]>
…than better

The passage said that pass STAYS, with the reason it had to. Both halves are
now false: linebreak v1.5.0 removed the reason and this branch removed the
pass. The witness (5 lines against the reference's 5, first three to 0.02pt)
and the corpus table — line agreement and exact page counts up, Σ|page error|
and divergence down — are stated together, because the tally and the error
disagree and a reader must see both.

Co-Authored-By: Claude Opus 5 <[email protected]>
@tannevaled
tannevaled merged commit 11de0a1 into main Nov 14, 2026
18 checks passed
@tannevaled
tannevaled deleted the ragged-background branch November 14, 2026 20:05
tannevaled added a commit that referenced this pull request Nov 14, 2026
…#781)

⛔⛔ A REGRESSION I MERGED THIS EVENING, FOUND BY #583's OWN WITNESS.

#780 gave the breaker a background carrying \leftskip and \rightskip — width,
stretch by order, shrink — which is tex.web §16307-16315. But this engine does
not keep line_width at \hsize: paragraph.go:81 hands breakSegment

	lineWidth := spToPt(e.hsize - e.leftskip.width - e.rightskip.width)

so the widths were already off the measure, and the background took them off
again. tex.web's arrangement and this engine's are the same arithmetic; doing
BOTH is not.

Measured on #583's witness (`\rightskip=100pt`, a 343.7pt measure, right margin
at 477.50), against tectonic 0.17.0:

	reference      3 lines, `A fairly long subsection title that has to wrap onto a`, x1 377.85
	before #780    3 lines, the same split,                                           x1 377.87
	#780           5 lines, `A fairly long subsection title that`, stretched to       x1 377.87
	now            3 lines, the reference's split again,                              x1 377.87

So #583's first defect was already fixed before #780, and #780 reopened it.

⛔ AND THE MARGIN COULD NOT SEE IT, WHICH IS WHY THE TEST PASSED. Every
assertion in TestLineSkipsNarrowTheMeasureBeforeBreaking measures how far right
the ink reaches, and that stayed correct through the double count: the lines are
justified to the narrowed measure either way. What moved was how much text the
breaker thought would fit — it packed less and stretched what it packed. Five
lines where the reference sets three, each stretched to the same right margin.

The test now asks the question of the TEXT: a paragraph at \rightskip=100pt must
not gain more than one line over the unconstrained one. Mutating the width back
in gives 6 lines against 3 and the assertion names the cause.

⚠ #768's witness is unchanged (five lines, the reference's five, lines 1-3 to
0.02pt), and the whole suite is green: the stretch half of the background — the
\raggedright fix that #780 was for — is untouched. Only the width is dropped.

⚠⚠ AND THE CORPUS A/B ON #780 MUST BE RE-RUN. Its table showed Σ|page error|
123 → 125 and mean divergence 3.884 → 3.935 against line agreement +0.11pt and
one more exact page count; part of that is likely this double count rather than
the change #780 was making. The machine's 1-minute load is above the threshold
at the time of writing, so it is owed, not done.

Refs #583, #768, #780.

Co-authored-by: Claude Opus 5 <[email protected]>
@tannevaled

Copy link
Copy Markdown
Contributor Author

The corpus A/B has been re-run clean, and it refutes what I said about it. The double count was not the cause of the page cost.

I wrote on #780 and #781 that part of Σ|page error| 123 → 125 was "likely this double count rather than the change #780 was making". That was a hypothesis stated as likely, and it is now measured false.

The clean run

gotex-refdiff -layout, 60 sampled at seed 1, between the exact commits — base be1decd (pre-#780), head 3afebd8 (#780 + #781). Load 5.65–7.55, under the ~8 threshold, so this one was taken properly; the earlier pair ran at 9–12.

base head
mean line agreement 91.35% 91.57% +0.22 pt better
mean divergence 3.833 3.872 +0.039 worse
page count exactly the reference's 12/41 12/41 ±0
Σ|page error| 124 126 +2 worse

41 papers scored on both sides, identical populations, no status flips — no reference-extraction flake this time, so nothing is excluded.

What changed, and what did not

Line agreement roughly doubled against the contaminated run: +0.22pt here against +0.11pt with the double count in place. So removing it did help, and the earlier figure understated the change's effect on lines.

Σ|page error| is still +2, and it is the same two papers as before:

2607.12864   article   ref 55   base 54 → head 53   MISSING PAGES
2607.01348   article   ref 36   base 34 → head 33   MISSING PAGES

Both were already under the reference and each loses one more page. The third mover from the contaminated run (2608.00249, PAGE OVERFLOW (+7)) no longer moves at all — that one was the double count.

So the honest reading

The change makes lines more like the reference and leaves page capacity slightly worse on the two tightest papers. Those two are #381's direction — our lines hold more than the reference's — and with hyphens no longer padding lines out to fill a measure, the papers that were already fitting too much fit a little more. Better line agreement does not fix a capacity bias, and on this sample it exposes it.

⚠ Not claimed: that #381 explains it. Two papers, one page each, named so anyone can check; the mechanism is a hypothesis and the measurement above is not a test of it.

⚠ And the retraction stands on its own: I attributed a cost to a defect because the defect was in front of me, and the defect was real but not the cause. The figures to cite for the #780+#781 pair are the ones in this comment, not the ones on #780.

🤖 Generated with Claude Code

tannevaled added a commit that referenced this pull request Nov 16, 2026
paragraph.go's note on the wide-open tolerance pass had accumulated three
generations, each appended above or below the last:

    ⛔⛔ THE WIDE-OPEN PASS STAYS, AND IT IS NOT TeX
    ⛔⛔ AND IT IS GONE
    ⛔ SO WHY IS IT STILL HERE
    ⚠ THE ORDER IS THEREFORE FIXED: ... then this pass goes

⛔ A reader cannot tell which tense is current, and one did not: #754's audit of
the delegated layers reports that this function "raises the tolerance to 1e4
instead (paragraph.go:251-258)", citing line numbers that by then pointed INTO
the comment rather than at code. The pass was already gone — there are exactly
two breaking calls in the file. A stale comment cost a published audit one of
its six findings.

Rewritten as one record in one order: what the pass was, what it cost (the #768
witness against tectonic 0.17.0, kept verbatim), why it could not simply go
(#778's six red tests, four of them a word that must be hyphenated going
unhyphenated), and why it is gone (linebreak v1.5.0's glue orders removed the
cause, #780 consumed them here).

Every measured number is kept. What is removed is the three tenses.

⚠ Two of the old headings survive as QUOTATIONS inside the sentence that
describes the defect, which is the point of them.

Co-authored-by: Claude Opus 5 <[email protected]>
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