Skip to content

test(sanitize): drop the optimization scaffolding - #3121

Merged
SamMorrowDrums merged 1 commit into
mainfrom
sammorrowdrums-drop-sanitizer-migration-scaffolding
Aug 19, 2026
Merged

test(sanitize): drop the optimization scaffolding#3121
SamMorrowDrums merged 1 commit into
mainfrom
sammorrowdrums-drop-sanitizer-migration-scaffolding

Conversation

@SamMorrowDrums

Copy link
Copy Markdown
Collaborator

Follow-up to #3120.

The benchmarks and the equivalence harness existed to justify the sanitizer rewrite and produce its before/after report. That job is done, so this removes them, including the verbatim copy of the old pipeline the harness carried:

  • pkg/sanitize/bench_test.go
  • pkg/sanitize/equivalence_test.go
  • pkg/github/minimal_types_bench_test.go

pkg/sanitize/sanitize.go is untouched. Net −560 lines.

What is deliberately kept

Five checks move into sanitize_test.go instead of going away. None of them reference the old implementation, so none are equivalence scaffolding, and each guards behaviour the rewrite introduced:

check why it stays
isHTMLInert is a fixed point of the live bluemonday policy — byte by byte, in context, and as whole strings, with the accepted byte set pinned explicitly This is the only thing standing between a future edit to htmlInertBytes and a silent change in sanitizer output. Verified by mutation: adding \r to the table fails with isHTMLInert accepted "a\rb" (byte 0x0D) but the policy rewrote it. Nothing else in the repo notices.
Both filters are fixed points on their own output This is what licenses Sanitize to skip its second invisible/code-fence pass. If it stops holding, the early return starts dropping work.
Clean ASCII sanitizes with zero allocations (testing.AllocsPerRun) The durable regression guard for the point of #3117, now that the benchmarks are gone.
Invalid UTF-8 is re-encoded to U+FFFD Carry-over from the []rune round trip the copy-on-write scan replaced; easy to lose by accident.
Known payloads still lose content Blunt check that no fast path passes an attack through untouched.

FuzzHTMLInertIsPolicyFixedPoint is kept for the same reason as the first row; the reference-diffing fuzz target is removed. Happy to strip these too if you'd rather have a clean sweep.

Validation

script/lint clean, script/test (race) green, 40s fuzz on the retained target clean.

The benchmarks and the reference-implementation equivalence harness
existed to justify the sanitizer rewrite. They have served that purpose,
so remove them along with the verbatim copy of the old pipeline they
carried.

Five checks move into sanitize_test.go rather than going away, because
none of them reference the old implementation and all of them guard
behaviour the rewrite introduced:

- isHTMLInert must be a fixed point of the live bluemonday policy,
  checked byte by byte and as whole strings, with the accepted byte set
  pinned explicitly. Nothing else fails if that set is widened, and
  widening it changes sanitizer output.
- Both filters are fixed points on their own output, which is what
  licenses Sanitize to skip its second pass.
- Clean ASCII sanitizes with zero allocations.
- Invalid UTF-8 is re-encoded to U+FFFD.
- Known payloads still lose content.

Net -560 lines.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@SamMorrowDrums
SamMorrowDrums requested a review from a team as a code owner August 19, 2026 14:41
Copilot AI balanced review requested due to automatic review settings August 19, 2026 14:41
@SamMorrowDrums
SamMorrowDrums force-pushed the sammorrowdrums-drop-sanitizer-migration-scaffolding branch from a2a9761 to 3e9d347 Compare August 19, 2026 14:41
@SamMorrowDrums
SamMorrowDrums merged commit 0bb1e56 into main Aug 19, 2026
18 of 20 checks passed
@SamMorrowDrums
SamMorrowDrums deleted the sammorrowdrums-drop-sanitizer-migration-scaffolding branch August 19, 2026 14:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes temporary sanitizer optimization benchmarks and equivalence scaffolding while retaining durable regression checks.

Changes:

  • Deletes sanitizer and converter benchmarks.
  • Removes the legacy reference-equivalence harness.
  • Moves essential sanitizer invariants into the main test suite.
Show a summary per file
File Description
pkg/sanitize/sanitize_test.go Adds retained invariant and regression tests.
pkg/sanitize/equivalence_test.go Removes legacy equivalence scaffolding.
pkg/sanitize/bench_test.go Removes sanitizer benchmarks.
pkg/github/minimal_types_bench_test.go Removes converter benchmarks.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Balanced


// TestFiltersAreIdempotent states the fixed-point properties that let Sanitize
// skip its second pass when HTML normalization changed nothing.
func TestFiltersAreIdempotent(t *testing.T) {
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.

2 participants