Skip to content

\sloppy is a no-op, and we refuse the overfull lines the reference accepts #768

Closed

Description

@tannevaled

Two findings from one witness, and the second is the larger one.

The witness

Same text, same 45pt measure, same face (lmroman10 at 10pt on both sides after #764). The only difference between the two paragraphs is the command:

\hsize=45pt
{\fussy  \noindent Typographical incomprehensibilities overwhelm every paragraph.\par}
{\sloppy \noindent Typographical incomprehensibilities overwhelm every paragraph.\par}

tectonic 0.17.0

\fussy                    \sloppy
Typographical             Typographical
incomprehen-              incompre-
sibilities over-          hensi-
whelm ev-                 bilities
ery paragraph.            over-
                          whelm
      5 lines             every
                          para-
                          graph.

                               8 lines

go-tex/engine

\fussy                    \sloppy
Typo-                     Typo-
graphical                 graphical
incompre-                 incompre-
hensibil-                 hensibil-
ities over-               ities over-
whelm                     whelm
every para-               every para-
graph.                    graph.

      8 lines                  8 lines   — identical

(1) \sloppy is a no-op here

latex.go:1353 is \def\sloppy{}. LaTeX's is \tolerance=9999 \emergencystretch=3em \hfuzz=.5pt \vfuzz=\hfuzz.

170 of 2935 corpus papers set \hyphenation; 775 set \sloppy — 26.4%, measured with comments stripped. \tolerance is plumbed (paragraph.go:195 reads e.namedInt("tolerance")), so defining the command would take effect today; \emergencystretch is accept-and-ignore and is go-typeset/linebreak#12 item (6).

⚠ And its effect is conditional, which is worth knowing before implementing it: at \hsize=100pt the same paragraph comes out identical under \fussy and \sloppy in the reference, because it already fits within \tolerance=200. A witness for \sloppy has to be a paragraph that genuinely fails at 200.

(2) The larger one: our default is already as loose as the reference's \sloppy

Our \fussy gives 8 lines where the reference's gives 5, and our 8 are close to what the reference produces only when asked to be sloppy.

The reference, at \tolerance=200, would rather set incomprehen-/sibilities over-/whelm ev-/ery paragraph. — four more-or-less full lines — than break the word three times. We break it three times by default.

That is the opposite of the long-standing corpus reading (#449, #381: "our lines hold MORE than the reference's"), and it is on the same channel: lines decide pages. It looks like the emergency pass at paragraph.go:251-258, which raises the tolerance to maxBadRatio when a bad line survives — a pass TeX reaches only with \emergencystretch set, and reaches differently (§863 adds stretch to the background; it does not widen the tolerance).

⚠ Not claimed: that (2) explains any part of the corpus deviation, or that the emergency pass is the cause rather than a candidate. What is measured is the 5-versus-8 above, on one witness, with the font and the measure controlled.

What I would do next, in this order

  1. Define \sloppy and \fussy properly — cheap, 26.4% of the corpus, and \tolerance already works.
  2. Then re-measure this witness. If our \fussy still gives 8, (2) is independent of (1) and is the real finding.

I have not done either: (2) changes paragraph breaking for every document and wants a corpus A/B behind it, not a witness.

Refs go-typeset/linebreak#12, #583, #381, #449.

🤖 Generated with Claude Code

Prior art: priorart "sloppy fussy tolerance emergency pass paragraph too loose" at 2026-11-12 21:47 CET reported prior art; checked: 368 entries. #194 (merged) brought TeX's two passes and the parameters a document sets — \tolerance is plumbed because of it, which is why (1) is cheap. #381 and #449 (open) read the corpus as 'our lines hold MORE', which the 5-vs-8 here contradicts on one witness and is why I am filing rather than appending. #754/#765 are my own audits and name neither \sloppy nor the emergency pass. #666 (closed) is \parfillskip, a different pass.

Activity

  1. tannevaled commented on Nov 13, 2026

    @tannevaled
    ContributorAuthor

    The control this issue was missing. #762 landed, so the question can now be asked instead of inferred.

    Same face, same space, same tolerance — and 5 lines against 8

    On the witness above (\hsize=45pt, Typographical incomprehensibilities overwhelm every paragraph.), both engines answer:

    tectonic 0.17.0 go-tex/engine
    \fontname\font [lmroman10-regular] lmroman10-regular
    \the\fontdimen2\font 3.33pt 3.33pt
    \the\tolerance 200 200

    The reference sets that paragraph in 5 lines and we set it in 8.

    So finding (2) is not a font difference wearing a line-breaking costume, and it is not a tolerance that was quietly different: with the face, the interword space and the badness threshold all identical, the two breakers reach different answers. That is as clean a separation as this witness can give.

    ⚠ What this does not establish. Which part of the breaker. The candidates named in the issue stand unchanged — the emergency pass at paragraph.go:251-258 raising the tolerance to maxBadRatio, and go-typeset/linebreak#12's missing glue orders — and nothing here chooses between them. It also remains one witness; the corpus A/B is a separate measurement and has not been run for this.

    ⚠ And one thing that is now measurable and was not. Before #762, confirming the face and the space meant rendering to SVG and subtracting glyph positions, which is how the font half of #449 and #612 had to be done. \fontname answers it directly, so the next person checking a breaking divergence can rule out the font in one line rather than in an afternoon.

    🤖 Generated with Claude Code

  2. tannevaled commented on Nov 13, 2026

    @tannevaled
    ContributorAuthor

    ⛔ Correcting myself: finding (2)'s characterisation is wrong, and the direction is the opposite of what I wrote.

    I said "our default breaking is already as loose as the reference's \sloppy". The measurement that follows says we are not looser — we are more eager to break.

    What the reference's log says

    The \fussy paragraph of that witness, at \hsize=45pt:

    Overfull \hbox (18.1pt too wide) in paragraph at lines 12--13
    Overfull \hbox (13.92pt too wide) in paragraph at lines 12--13
    Overfull \hbox (14.3pt too wide) in paragraph at lines 12--13
    Overfull \hbox (18.16pt too wide) in paragraph at lines 12--13
    

    Four overfull lines, up to 18.16pt past a 45pt measure. That is where its 5 lines come from: it sets Typographical whole, overhanging the margin by a third of the measure, rather than hyphenate it.

    Our 8 lines all fit. We hyphenate five times and stay inside the measure; the reference hyphenates three times and spills.

    So the diagnosis changes

    Not "we are looser" but "we will not leave a line overfull, and TeX will".

    tex.web's breaker deactivates a node when nothing feasible exists there and ends up recording the forced break with its overfull line; the engine's wide-open pass (paragraph.go:251-259, tolerance raised to maxBadRatio) instead finds a feasible solution by taking more hyphens. Both are "the last pass", and they resolve the same dead end in opposite directions.

    That also puts this issue beside #583 — "an overfull line with fill glue is accepted" — rather than opposite it: the two are about where the overfull/feasible boundary sits, from the two sides.

    What survives from the original finding, and what does not

    Survives: the 5-versus-8 itself, and its control — same face (lmroman10-regular), same \fontdimen2 (3.33pt), same \tolerance (200), verified with #762. It is a line-breaking divergence and not a font one.

    Does not survive: "looser". Nor the suggestion that raising our tolerance further explains it — if anything our willingness to hyphenate is what needs reducing, not our tolerance.

    Still open and now better posed: which pass. The candidates are unchanged — the wide-open pass here, and go-typeset/linebreak#12's missing glue orders — but the question to ask them is now "why does the dead end resolve to hyphens here and to an overfull line there" rather than "why are we looser".

    ⚠ And the \sloppy half of this issue is unaffected: \sloppy was \def\sloppy{} and is now implemented (#769), whose own A/B showed it changes one paper of 37 and slightly for the worse — consistent with the corrected reading, since asking for more tolerance does nothing about a breaker that was never short of tolerance.

    🤖 Generated with Claude Code

  3. changed the title [-]\sloppy is a no-op, and our default breaking is already looser than the reference's \sloppy[/-] [+]\sloppy is a no-op, and we refuse the overfull lines the reference accepts[/+] on Nov 13, 2026
  4. tannevaled commented on Nov 14, 2026

    @tannevaled
    ContributorAuthor

    Finding (2) is located: it is the wide-open pass, and removing it gives the reference's five lines. #778 (draft).

    The witness, four ways

    \hsize=45pt, \fussy, face and \tolerance verified identical as in the comment above:

    lines
    tectonic 0.17.0 5, four overfull (18.1, 13.92, 14.3, 18.16pt)
    before 7, all fitting
    FinalPass armed 7
    armed, wide-open pass removed 5, lines 1–3 the reference's to 0.02pt

    paragraph.go:319 breaks the paragraph again at \tolerance=maxBadRatio whenever the pass above left a bad line. tex.web has no such pass — §863 has three, and none of them raises the tolerance. The pass above had already found the reference's answer; this one threw it away, because hasBadLine is true of a solution TeX deliberately chose. At \tolerance=200 a short line with no stretch has badness 10000 and is not feasible, so TeX overhangs rather than hyphenate. That is this issue's corrected diagnosis read from the other side.

    What unblocked it

    Params.FinalPass could not be armed while go-typeset/linebreak recorded every forced break whatever its badness and ran artificial_demerits outside §16769's branch. Both are that package's #12 item (5) and its neighbour, fixed in v1.4.0. With the flag armed, §863's final_pass:=(emergency_stretch<=0) is simply what this engine's second pass is.

    And the last divergence on the witness was not the breaker at all

    The reference sets whelm ev-/ery para- where we set whelm/every para-. The engine embedded ushyphmax.tex and loaded all of it: hyphen.tex's patterns, a marker, then 492 additions. LaTeX loads hyph-en-us.tex — the first half. .ev2 is an addition and outranks hyphen.tex's ev1er at the same position; 2 is even, so it forbids the break. every had no break point at all. tectonic at \hsize=18pt sets ev-/ery, and so do we now; the other words of this witness break exactly where they did.

    Why the pass is not removed in #778

    Four tests go red without it, all saying a word that must be hyphenated stops being hyphenated: linebreak#12 item (1) — one float of stretch, plus 1fil flattened to a large finite number — makes a \raggedright line TeX scores at badness 0 score 10000 here, so TeX's pass 2 has a feasible solution and hyphenates inside it while ours has none and takes the single overfull line. The wide-open tolerance hides that by making everything feasible.

    Order: linebreak#12 item (1), then the pass, then this issue.

    ⚠ Not claimed: any corpus effect. The A/B is owed on #778 and has not run — the machine's 1-minute load is 62.

    🤖 Generated with Claude Code

  5. tannevaled commented on Nov 14, 2026

    @tannevaled
    ContributorAuthor

    Finding (2) is fixed and on main — #780, merged, CI green at 11de0a1.

    The wide-open maxBadRatio pass is gone. It could not go until the two things it was standing in for were real, which took three releases:

    go-typeset/linebreak v1.4.0 §16769's branch read whole: a forced break past the threshold deactivates, and artificial_demerits lives inside that branch
    #778 the second pass is the final pass (§863), so TeX's last resort is reachable here at all
    go-typeset/linebreak v1.5.0 glue orders are classes (§16790-16793) and \leftskip/\rightskip are the background of every line (§16307-16315)
    #780 the engine consumes both; the fourth pass removed

    On this issue's own 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. This morning: seven.

    ⚠ What is left of this issue. Finding (1), \sloppy, is implemented in #769 and still a draft: it was held pending this, on the reasoning that raising the tolerance "asks for more of what we already do too much of". That reasoning is now obsolete — the breaker is no longer too loose — so #769's own A/B is worth re-running against this main, which is exactly the test it said to run.

    ⚠ And the residue on the witness is not the breaker: ev-ery is a hyphenation point the reference takes on the same patterns and we do not. Separate from both findings.

    ⚠ Not claimed: a corpus gain. Over 40 papers line agreement went 91.23 → 91.34% and exact page counts 12 → 13/40, against Σ|page error| 123 → 125 and divergence 3.884 → 3.935. The full table is on #780; two of the three papers that moved a page are #381 showing through.

    🤖 Generated with Claude Code

  6. tannevaled commented on Nov 15, 2026

    @tannevaled
    ContributorAuthor

    The ev-ery residue is not hyphenation: the break is offered and the breaker declines it. One probe settles which half to look at, which the earlier note left open.

    Asked of the hyphenator this paragraph actually uses, at main:

    mins left=2 right=3
    every        points=[2]      ev-ery
    overwhelm    points=[4]      over-whelm
    paragraph    points=[4]      para-graph
    simplicial   points=[3 6]    sim-pli-cial
    hyphenation  points=[2 6]    hy-phen-ation
    

    ev-ery is there, at exactly the position the reference takes, and the min-affix limits (2 left, 3 right) admit it. So the discretionary reaches the horizontal list and the line breaker then does not use it.

    That removes the two candidate explanations that would have been about patterns — a missing pattern, or a \lefthyphenmin/\righthyphenmin that forbids a two-letter prefix — and leaves the one recorded earlier on this issue: our active list retains a node TeX deactivates, so the onlyActive clause that authorises an artificial break cannot fire. Unmeasured; this comment narrows where to look rather than claiming the mechanism.

    ⭐ hy-phen-ation is also worth one line, since it is the word TeX's own manual uses as its example of what hyphen.tex gets right, and we get the same two points.

    ⚠ Not claimed: that the breaker is wrong to decline it. Both sides set five lines on this witness; the residue is which break fills them, and nothing here says whose choice has the lower demerits.

    🤖 Generated with Claude Code

  7. tannevaled commented on Nov 15, 2026

    @tannevaled
    ContributorAuthor

    Retiring the hypothesis I left on this issue. I read tex.web §16824-16831 and the breaker's own code against it, and the artificial-demerits clause is implemented faithfully — including the part I suspected.

    What I had recorded was: our active list may retain a node TeX deactivates, so the onlyActive clause cannot fire. The source says:

    @<Prepare to deactivate node~|r|, and |goto deactivate| unless...@>=
    begin if final_pass and (minimum_demerits=awful_bad) and
       (link(r)=last_active) and
       (prev_r=active) then
      artificial_demerits:=true {set demerits zero, this break is forced}
    else if b>threshold then goto deactivate;
    node_r_stays_active:=false;
    end
    

    with Knuth's own warning two lines above it: "This particular part of TeX was a source of several subtle bugs before the correct program logic was finally discovered; readers who seek to 'improve' TeX should therefore think thrice before daring to make any changes here."

    go-typeset/linebreak v1.5.0 linebreak.go:397-399:

    desperate := r < -1 || forced
    artificial := p.FinalPass && desperate && onlyActive &&
        bestHere[0] == nil && bestHere[1] == nil && bestHere[2] == nil && bestHere[3] == nil

    Term by term: final_pass → p.FinalPass; the enclosing branch (b>inf_bad)or(pi=eject_penalty) → desperate; link(r)=last_active and prev_r=active → onlyActive (len(active) == 1); minimum_demerits=awful_bad → all four bestHere entries nil, which is right because minimum_demerits "keeps track of the smallest value in the minimal_demerits array" (§16432-16433) across the four fitness classes, not one of them.

    ⭐ And the one place those two could have diverged, they cannot. minimum_demerits is reset mid-walk, at §16490-16492, each time the line-number class changes — so in principle TeX could fire the clause for a later line class after recording a break for an earlier one, where bestHere would still be full. It cannot happen: prev_r=active requires r to be the first active node and link(r)=last_active the last, so the clause is only ever reached with one active node and therefore one line-number class, and no mid-walk reset has occurred. The two conditions are equivalent, and the shortcut is sound.

    So the ev-ery residue is not this clause, and it is not hyphenation either (the previous comment: the break is offered at exactly the reference's position). What is left is the demerits arithmetic choosing a different break among feasible ones — \adjdemerits, \doublehyphendemerits, \finalhyphendemerits, the fitness classification — which is a different investigation from the one I had queued, and a smaller claim than "a node is retained".

    ⚠ One structural observation from the same reading, unfiled

    KnuthPlassWith(items []Item, lineWidth float64, p Params) takes one lineWidth for the paragraph, and the per-position loop keeps one bestHere[4] across the whole active list. tex.web keeps minimal_demerits[fit_class] per (line-number class, fitness class) and flushes it whenever l > old_l while walking (§16461-16472), with easy_line as the optimisation for the case where every line has the same width.

    For a uniform paragraph the two agree exactly, which is why nothing has shown it. For \parshape and \hangindent — where the width is a function of the line number — there is no way to express the width through this API at all, so the line-number-class dimension has no counterpart rather than a wrong one.

    ⛔ Not filed, deliberately: priorart --repo go-tex/engine "parshape hangindent per-line width in the line breaker" exited 2 — the tracker and the branch list were both unread, stopped at the API budget reserve (715 left, 1000 held back). An unread surface is not an absence of prior art, and this repository has a hangindent branch I already know of, so filing now would risk duplicating work I simply could not look for. Recording it here so it is not lost, to be checked against the tracker when the budget allows.

    ⚠ Not claimed: that the collapse is a defect. For every witness on this issue it is exactly equivalent; whether it matters is a question about documents this breaker cannot currently be asked about.

    🤖 Generated with Claude Code

  8. tannevaled commented on Nov 15, 2026

    @tannevaled
    ContributorAuthor

    The obvious next instrument — ask the reference to print its own demerits — does not exist in the reference we have, and tex.web says precisely why.

    Having narrowed the ev-ery residue to the demerits arithmetic, the right oracle is \tracingparagraphs: TeX prints b, p and d for every feasible break it considers, so the reference states its own reason instead of being inferred from its output. Run on this issue's witness against tectonic 0.17.0:

    \documentclass{article}
    \tracingparagraphs=1
    \tracingonline=1
    \begin{document}
    \hsize=45pt
    \hbadness=10000 \tolerance=10000
    Typographical incomprehensibilities overwhelm every paragraph.
    \end{document}
    b=                0 hits in the log
    lines starting @  0
    firstpass/secondpass markers  0
    

    Tried both in the preamble and in the body, with \tracingonline 0 and 1, reading both the log and stdout. The Overfull \hbox (33.1pt too wide) is there, so the paragraph was broken and the log was written.

    ⛔ And the positive control, because an absent trace and a stripped log look identical. \tracingcommands=1 on the same engine, same flags:

    {vertical mode: \tracingonline}
    {horizontal mode: \global}
    {vertical mode: \endgroup}
    

    Six hits. So tracing works; it is this trace that is missing.

    Why, from tex.web

    Every tracing_paragraphs site in tex.web sits inside the @!stat … tats conditional — the WEB section that a build can omit:

    16292:  @!stat if tracing_paragraphs>0 then end_diagnostic(true);@+tats@;
    16301:  @!stat if tracing_paragraphs>0 then begin_diagnostic;@+tats@;
    16659:@!stat if tracing_paragraphs>0 then
    16843:@!stat if tracing_paragraphs>0 then
    16989:  begin @!stat if tracing_paragraphs>0 then
    17013:    begin@!stat if tracing_paragraphs>0 then print_nl("@@secondpass");@;@+tats@/
    17021: done: @!stat if tracing_paragraphs>0 then
    

    — nine of them, and the same for tracing_pages, tracing_restores and tracing_stats. tracing_commands is not:

    20074:if tracing_commands>0 then show_cur_cmd_chr
    

    A bare if. So a TeX compiled without the stat section emits \tracingcommands and emits no paragraph trace — exactly the asymmetry measured above. The control and the source agree, which is what makes this a finding about the build rather than a guess about tectonic.

    (No other TeX is installed here: which pdftex xetex luatex tex etex finds none.)

    What follows

    1. The oracle is recoverable from a stat-enabled build — a standard web2c tex/pdftex would print it. Worth having on the measurement host for this class of divergence, and it is the cheapest route to the reference's own demerits.
    2. Meanwhile our side is not inspectable either: \tracingparagraphs is in texparams.go:25 as an accepted count with no effect, so neither engine can currently be asked why it chose a break. tex.web §16854-16874 gives the exact format, and emitting it needs a trace hook in go-typeset/linebreak (the demerits live there) with the engine wiring the parameter to it. That makes every future break divergence a diff of two traces instead of an inference from glyph positions.

    ⚠ Not claimed: that tectonic is at fault, or that its maintainers disabled anything deliberately. What is measured is that this binary does not emit the trace while it does emit another, and tex.web explains how that combination arises.

    🤖 Generated with Claude Code

  9. tannevaled commented on Nov 15, 2026

    @tannevaled
    ContributorAuthor

    A sourced fix landed, and it does NOT move this witness. Saying so before anyone reads the merge as progress on ev-ery.

    Following the narrowing to the demerits arithmetic, go-typeset/linebreak#15 is merged: the paragraph-ending break is tex.web:17198's distinguished call try_break(eject_penalty,hyphenated), so at that break the test (break_type=hyphenated)and(type(r)=hyphenated) reduces to "was the previous break a hyphen", and cur_p=null selects \finalhyphendemerits. The caller had atEnd = b == n (the last line ends at the forced penalty, not at n) and flagged = flaggedAt(items, b) (a \penalty-10000, never flagged), so neither parameter was charged and a hyphen on the last line but one was free. Both halves mutate red by assertion.

    Measured on this witness, with the fix linked

    go.mod replaced to the fixed clone, confirmed in effect (go list -m → v1.5.0 => …/linebreak-finalhyph), engine at main 4d20b7b:

    overfull=2   worst=33.10pt
    Typographical / incompre- / hensibil- / ities / over- / whelm / every / para- / graph.
    

    No ev-. Identical to before: whelm then every para-, two overfull lines where the reference has one.

    Why it cannot move it, which is the useful part

    Both candidate solutions end the same way:

    reference   … whelm ev- | ery para- | graph.
    ours        … whelm     | every para- | graph.
    

    The penultimate break is para- — a hyphen — in both. So \finalhyphendemerits is now charged to both and cancels. The fix is real and it is invisible here by construction.

    ⚠ And the charge TeX adds that we still do not goes the other way: the reference's para- break has type(r)=hyphenated (r is ev-), so TeX also charges it \doublehyphendemerits — 10000 — and the reference still wins. Whatever makes ev-ery cheaper for TeX is worth more than 10000 demerits, so it is not a demerits term that is missing. It is the badness of those lines.

    Which points at a filed divergence, verified here

    go-typeset/linebreak#12 item (2): widths go into prefix sums, so a penalty's width is charged to every line that does not break there, where tex.web §869-§870 add disc_width only for the break being tried. This engine's workaround is in its own words, paragraph.go:580-588:

    case discNode:
    	// … The width is 0: the hyphen glyph is real material only on the line that
    	// breaks here (layoutSegment appends it), and the linebreak library folds
    	// a penalty's width into the running line total even when the break is NOT
    	// taken there — so a non-zero width here would inflate every line holding
    	// an unbroken hyphenation point.
    	items[i] = Penalty(0, float64(c.penalty), true)

    So the line that does break at a hyphen is measured without the hyphen it will carry — about 2.5pt at 10pt, on a 45pt measure. whelm ev- is scored as if it were a hyphen narrower than it will be set, and so is every para-. That is a badness error of the right size and in the right place to decide this break, and it is exactly what item (2) describes.

    ⚠ Not claimed: that item (2) explains ev-ery. It is now the leading candidate with a mechanism and a measured address, not a demonstrated cause — the previous two candidates (the artificial-demerits clause, then hyphenation itself) were each eliminated by measurement rather than argued away, and this one deserves the same treatment.

    ⚠ Also not claimed: that #15 helps anywhere. On this witness it is neutral by cancellation; its effect is on paragraphs whose penultimate break is a hyphen where the alternative's is not, and no corpus figure is offered — the machine's 1-minute load average is 14.6, over the ~8 threshold, so the A/B is deferred rather than taken badly.

    🤖 Generated with Claude Code

  10. tannevaled commented on Nov 15, 2026

    @tannevaled
    ContributorAuthor

    The instrument exists now, and the engine side is one API decision — which reading Options settles. Writing it here rather than as its own issue, for a reason stated at the bottom.

    go-typeset/linebreak v1.7.0 ships Params.Trace, an io.Writer carrying TeX's own paragraph log in tex.web's format:

    @ via @@0 b=10000 p=0 d=100010000
    @@1: line 1.0 t=100010000 -> @@0
    @\discretionary via @@0 b=1 p=50 d=2633
    @@2: line 1.2- t=2633 -> @@0
    @\penalty via @@1 b=10000 p=100 d=100010000
    @\par via @@3 b=0 p=-10000 d=10100
    

    Emitted where tex.web emits it — the feasible break at :16843, inside "Record a new feasible break" and before the champion comparison, so every break considered appears and not only the winners; the active node at :16659, as it is linked in, which is where the serial is assigned. A test pins that the breaking is identical with the log on and off.

    What the engine needs, and the one thing that had to be decided

    ⛔ Options has no log destination at all. Diagnostics is a struct returned after the compile, not a stream, and nothing in Options takes a writer or a callback. So the trace cannot be wired without adding a field, which is why this was worth settling before writing code rather than during.

    Options.Trace io.Writer is the right shape, for three reasons: a trace is a stream and can be megabytes on a real document, so it does not belong in a summary struct; io.Writer lets a host send it to a file, which is where TeX puts it; and it composes with linebreak.Params.Trace without translation.

    The insertion points are small and already in one place:

    • paragraph.go:205-212 builds LineBreakParams — set Trace there when e.namedInt("tracingparagraphs") > 0 and opt.Trace != nil.
    • The pass markers are the caller's, and the passes are right there too: the \pretolerance pass builds its own q at :213-215, so @firstpass, @secondpass and @emergencypass (:16990, :17013, :17017) go around the three.
    • texparams.go:25 already accepts \tracingparagraphs as a named count, so no parameter plumbing is needed — only that its value stop being ignored.

    ⚠ \tracingonline cannot be honoured and should be documented as such rather than faked. It selects between TeX's log file and its terminal; with a single writer there is one destination, and pretending otherwise would be a parameter that reads as working and does nothing.

    ⛔ And the trace cannot arrive on its own. v1.7.0 also carries v1.6.0's \finalhyphendemerits fix, which changes paragraph breaking, so the bump owes the corpus A/B that #784 is already held for — the host's 1-minute load average has been 14.6, then 22.3, then 133 today, all far over the ~8 threshold this repository measures under. Whoever takes it should either fold it into #784 or wait; what it must not be is merged as "just a feature" because the trace half is harmless.

    ⚠ Not filed as its own issue, deliberately. priorart --repo go-tex/engine "tracingparagraphs wire the line breaker trace to a writer" exited 2: the tracker and the branch list were both unread, stopped at the API budget reserve (525 left, 1000 held back). An unread surface is not an absence of prior art, and this repository has 1032 entries on the neighbouring subject — filing now could duplicate something I simply could not look for. This comment keeps the design where its purpose lives until the budget allows the check.

    🤖 Generated with Claude Code

  11. tannevaled commented on Nov 15, 2026

    @tannevaled
    ContributorAuthor

    The instrument works, I pointed it at this witness, and it says the search I was conducting could not have succeeded: on this paragraph the demerits cannot discriminate at all.

    go-typeset/linebreak v1.7.0's trace, wired to breakSegment in a throwaway worktree (not committed — the real wiring is the Options.Trace design in my previous comment), on this issue's own witness:

    @ via @@0 b=* p=0 d=*
    @@1: line 1.3 t=0 -> @@0
    @\discretionary via @@1 b=10000 p=50 d=100012500
    @@2: line 2.0- t=100012500 -> @@1
    …
    @\discretionary via @@7  b=4140 p=50 d=17236701
    @\discretionary via @@10 b=1027 p=50 d=1089420
    @\discretionary via @@11 b=51   p=50 d=16288
    @\par via @@14 b=0 p=-10000 d=5100
    @@15: line 7.2- t=317283089 -> @@14
    

    52 trace lines, 35 scored breaks. Counted:

    breaks with badness at the 10000 cap 31 of 35
    the same breaks with demerits at TeX's 1e8 ceiling 31
    breaks with unsaturated badness 4 — 4140, 1027, 51, 0

    ⛔ So 31 of 35 candidates cost exactly the same thing. §16902 sets d:=100000000 whenever |line_penalty+b| >= 10000, and §108 caps badness AT inf_bad, so every one of those lines is charged the ceiling and nothing distinguishes them. The paragraph's total, 317 283 089, is three saturated terms plus loose change.

    \doublehyphendemerits is 10000. \finalhyphendemerits is 5000. A hyphen penalty squared is 2500. Those are the quantities that would decide whelm ev- against whelm — and they are four orders of magnitude below the 1e8 terms they are being added to. The demerits arithmetic cannot see the difference, whatever it contains.

    That explains two dead ends in this issue's own history rather than merely adding a third: the artificial-demerits clause was faithful (measured), and go-typeset/linebreak#15's \finalhyphendemerits fix was neutral here (measured) — not because either was wrong, but because this witness saturates the cost function, and I was looking for a term in a sum that cannot resolve it.

    ⚠ And the witness is partly doing it to itself

    The source sets \tolerance=10000, which is what makes a badness-10000 line feasible rather than refused. A paragraph at \tolerance=200 would have had those 31 candidates rejected and the passes would have done the work instead. So this is a statement about this witness, not about the breaker in general.

    ⭐ Which gives this issue something concrete it has been missing: a better witness. For the ev-ery question to be answerable, the competing breaks must have badness well under the cap, so that demerits decide and the trace shows them deciding. The witness to build is a paragraph where our breaking and the reference's differ by one hyphen and every line is merely bad — not one where seven lines are hopeless and the eighth is the question.

    And it corroborates the lead, by a second route

    If 31 of 35 lines come out at the badness cap, the suspicion falls on what badness is computed FROM. go-typeset/linebreak#12 item (2) — the hyphen's width charged to every line that does not break there, so the line that does break at a hyphen is measured about 2.5pt short on a 45pt measure — is a systematic error in exactly that input. Reached here from the demerits side, having reached it earlier from the cancellation side, which is two independent routes to the same place.

    ⚠ Not claimed: that item (2) explains ev-ery. Still a lead, now with two reasons to look there and one fewer place left to look.

    🤖 Generated with Claude Code

  12. tannevaled commented on Nov 16, 2026

    @tannevaled
    ContributorAuthor

    Both findings have landed. Closing, with the witnesses rather than an assertion —
    and with one correction to what this issue predicted.

    (1) \sloppy is no longer a no-op

    latex.go:1376-1377 is LaTeX's own pair:

    \def\sloppy{\tolerance 9999\emergencystretch 3em\hfuzz .5pt\vfuzz\hfuzz}
    \def\fussy{\emergencystretch 0pt\tolerance 200\hfuzz .1pt\vfuzz\hfuzz}

    and \emergencystretch is no longer accept-and-ignore: paragraph.go:390-408
    reads the dimen, sets FinalPass = emergency <= 0 as tex.web:17014 does, and
    runs §863's third pass with the stretch in the background when the second
    pass leaves a bad line.

    Measured just now on this checkout, same document under each command:

    overfull lines worst
    \fussy (\emergencystretch 0pt) 3 10.92 pt
    \sloppy (\emergencystretch 3em) 0 0.00 pt

    (TestEmergencyStretchReachesTheBreaker, with
    TestWithoutEmergencyStretchNothingChanges as the control: at zero stretch
    \fussy and the default must agree, or the third pass is firing when TeX's would
    not.)

    This issue counted 775 of 2935 corpus papers setting \sloppy — 26.4%.

    (2) Our default was as loose as the reference's \sloppy — and that pass is gone

    The cause was named here as a candidate and it was the right one: the home-made
    emergency pass that raised the tolerance to maxBadRatio. Nothing in tex.web
    does that — §863 has exactly three passes and none of them widens the threshold;
    the third adds \emergencystretch to the background.

    It went with #780, and the measurement is recorded at paragraph.go:431-443
    against tectonic 0.17.0 on this issue's own witness (\hsize=45pt, \fussy):

    lines
    reference 5 four overfull boxes (18.1, 13.92, 14.3, 18.16 pt)
    with the pass 7 every line fitting
    without it 5 lines 1-3 the reference's to 0.02 pt

    Pass 2 had already found the reference's answer and the extra pass threw it away,
    because hasBadLine is true of a solution TeX deliberately chose: at
    \tolerance=200 a short line with no stretch has badness 10000 and is not
    feasible, so TeX overhangs the margin rather than take the hyphens.

    ⛔ Why it could not simply be deleted, which is the part worth keeping: one
    removal attempt (#778) turned six tests red, four of them saying a word that
    must be hyphenated had stopped being hyphenated. That was
    go-typeset/linebreak#12 item (1) seen from here — the library carried one float of
    stretch and flattened 0pt plus 1fil into a large finite number, so a line TeX
    scores at badness 0 scored 10000 here and was infeasible. The wide-open tolerance
    had been hiding that. The library's v1.5.0 carries the glue orders and makes
    \leftskip/\rightskip the background; #780 consumed it and the pass went with
    the cause.

    The correction

    ⚠ This issue proposed the order "define \sloppy first, it is cheap, then
    re-measure". That order was right but the reasoning under it was not: while the
    emergency pass existed, \sloppy's \tolerance 9999 would have been invisible,
    because the engine already behaved as though the tolerance were 10000 whenever a
    bad line survived. (1) could only be observed after (2) was fixed. The two were
    not independent, and this issue's step 2 — "if our \fussy still gives 8, (2) is
    independent of (1)" — had the dependency the other way round.

    ⚠ Not claimed: that either change moved the corpus. Neither has a measured
    corpus cost here. What is measured is the two tables above.

    Closes #768.

    🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions