Urgent.News

What's breaking now, across thousands of outlets.

Tech

Your Refactor Needs an Oracle: Characterization Tests vs. AI Diffs

AI-generated refactors fail silently. The code looks clean. The tests pass. Then a production edge case breaks. Characterization tests catch that break before it ships. This workflow locks current behavior first, then lets a free model propose changes, then uses tests as the oracle. The Problem Legacy code has undocumented quirks. Humans miss them. Models miss them too. A refactor that changes a…

AI-generated code refactors can introduce unexpected bugs that only surface in production environments. To avoid this, developers should use characterization tests alongside AI-generated code changes. Characterization tests capture the current behavior of legacy code, ensuring that any refactor doesn't change the expected output.

The process involves writing tests for known inputs, including edge cases like zero or negative values, then running the AI-generated refactor and re-running the tests. If the tests pass, the refactor is considered safe. However, if tests fail, the issue lies in the changed behavior, not the model's output. This method helps developers maintain code stability while leveraging AI for efficiency, though it's not a perfect solution for safety-critical systems or tightly coupled code.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Token Service Isolation: Containing Customer Support Chat Reconnect and Backfill Failures

Short answer: isolate token issuance from the chat data path, scope each token to one tenant, conversation, actor, and capability, then make reconnect depend on a durable cursor rather than on…

  • Isolate token issuance from chat data path to contain failures
  • Use durable cursor for reconnect mechanisms, not token info
  • Token service issues short-lived, audience-bound authority

One Command to Verify an Agent Patch: Seeded Hypothesis, Fixture Contracts, and a TTL Quarantine

One Command to Verify an Agent Patch: Seeded Hypothesis, Fixture Contracts, and a TTL Quarantine A merge gate should be a single command, not a mental checklist.

  • Seeded property checks verify agent-patched Python projects using Hypothesis library
  • Fixture contracts define domain contracts to catch issues early from fixture loader changes
  • TTL quarantine handles flaky tests by excluding them for a fixed duration before re-enabling

More from Tuesday 1 September →