Backtestshugorun-20260917-015623#15267

Issue #15267 Merged fix PR # Run 17 Sep 2026 · run-20260917-015623 gohugoio/hugo

Bump fileCacheEntryVersion in transform.ToMath

Par

Our patch was judged on par with the merged fix.

In this judgment, Patch A = our agent, Patch B = the merged fix.

The two diffs are byte-for-byte identical. Both change the single line `const fileCacheEntryVersion = "v1"` to `"v2"` in tpl/transform/transform.go, at the same location, with no other edits. This is exactly the correct root-cause fix: the KaTeX bump from 0.16.21 to 0.18.4 produces different math output, so cached entries keyed under the old version must be invalidated; bumping the entry version to v2 forces regeneration and the comment already instructs incrementing on incompatible changes. Neither patch adds tests (a cache-version bump is not meaningfully unit-testable and none is expected), both are minimal in scope, and craft is equal because they are the same text. With no difference on any criterion — correctness, tests, scope, or craft — this is a genuine tie.

The judge saw only the two patches, labelled A and B in random order, with issue links and version numbers removed. The reasoning above is shown verbatim.

Solve

6m 2s1 turn

Wall-clock time in the container

Full test suite

No new failures

3,749 passed · 99 skipped · 3,854 total

Contamination audit

Unknown

See the audit notes for this run

Patch size

2vs 2 merged

Changed lines, ours vs merged

In ec52e638c we bumped KaTeX from 0.16.21 to 0.18.4. This produces different output.

I ran into this when testing the docs site, specifically the chem example.

The two patches

Our patch+1 −1
tpl/transform/transform.goindex 5c99b322c..f9d0dabb0 100644@@ -293,7 +293,7 @@ func (ns *Namespace) ToMath(ctx context.Context, args ...any) (template.HTML, er 		Warnings []string `json:"warnings,omitempty"` 	} -	const fileCacheEntryVersion = "v1" // Increment on incompatible changes.+	const fileCacheEntryVersion = "v2" // Increment on incompatible changes.  	s := hashing.HashString(args...) 	key := "tomath/" + fileCacheEntryVersion + "/" + s[:2] + "/" + s[2:] 
Merged fix · PR #+1 −1
tpl/transform/transform.goindex 5c99b322c..f9d0dabb0 100644@@ -293,7 +293,7 @@ func (ns *Namespace) ToMath(ctx context.Context, args ...any) (template.HTML, er 		Warnings []string `json:"warnings,omitempty"` 	} -	const fileCacheEntryVersion = "v1" // Increment on incompatible changes.+	const fileCacheEntryVersion = "v2" // Increment on incompatible changes.  	s := hashing.HashString(args...) 	key := "tomath/" + fileCacheEntryVersion + "/" + s[:2] + "/" + s[2:] 

What the agent reported

Reviewer confirms PASS. The fix is complete and verified.

Summary

What was wrong
Commit ec52e638c upgraded KaTeX from 0.16.21 to 0.18.4, which produces different rendered math output. Hugo's transform.ToMath caches its rendered output on disk (the MiscCache file cache), keyed by "tomath/" + fileCacheEntryVersion + .... Because that version constant was never bumped, sites with a pre-existing cache (e.g. the docs site's chem example) would keep serving the old KaTeX 0.16.21 output from the stale cache instead of the new output. The constant's own comment states it must be incremented on incompatible changes.

What I changed
A single-line, minimal edit in tpl/transform/transform.go:296:

-	const fileCacheEntryVersion = "v1" // Increment on incompatible changes.
+	const fileCacheEntryVersion = "v2" // Increment on incompatible changes.

This changes the cache key prefix, orphaning all stale tomath/v1/... entries so the new KaTeX output is regenerated and cached under tomath/v2/....

Test evidence

  • Gate: ./bt-test -run 'TestToMath' ./tpl/transform/ — all ToMath tests pass, and the github.com/gohugoio/hugo/tpl/transform package passes (TestToMath, TestToMathError + 4 subtests, TestToMathBigAndManyExpressions + 2 subtests, TestToMathRenderHookPosition, TestToMathMacros, TestToMathStrictMode).
  • Reviewer: PASS — confirmed the diff is exactly the one-line "v1"→"v2" change with the comment intact, and no unrelated source files were touched (the AGENTS.md/CLAUDE.md deletions shown in git diff --stat were pre-existing in the working tree before this task).

Note on regression testing
I deliberately did not add a regression test. This is a cache-invalidation version bump with no test-observable behavior: the existing ToMath tests assert on output substrings (<span class="katex"><math, etc.) that pass regardless of the constant's value, and there is no golden-output or KaTeX-version test in the repo. The only "test" one could write would assert the literal constant equals "v2", which is a change-detector that adds no real coverage. The verification here is that all existing ToMath tests continue to pass with the bumped version.

All changes are left uncommitted in the working tree.