When you fix behavior (especially edge/boundary cases), add regression tests that are:

Apply like this:

Example (boundary regression + meaningful failure):

// Arrange
const LIMIT = 10;
// Restoring a buggy form should make this test fail.
function fixedAppend(current: string, next: string) {
  if (!next) return current;
  if (current.length >= LIMIT) {
    const keep = LIMIT > next.length ? LIMIT - next.length : 0;
    if (keep <= 0) return next.slice(-LIMIT);
    return current.slice(-keep) + next;
  }
  return current + next;
}

// Assert (exact boundary)
import test from "node:test";
import assert from "node:assert/strict";

test("appendBoundedText clamps at limit", () => {
  const cur = "x".repeat(LIMIT);
  const next = "y".repeat(LIMIT);
  assert.equal(fixedAppend(cur, next), next); // should be clamped
});

Also add guard assertions when you have rule systems/transform pipelines so that “no-op” rules (e.g., patterns that never change anything) can’t be introduced unnoticed.