Urgent.News

What's breaking now, across thousands of outlets.

AI

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 AI

The Hugging Face hack

That is the topic of my latest Free Press column. Some people are taking this in very dramatic fashion: One commentator is worried about a “full-blown AI takeover within months,” and another wrote…

  • Hugging Face hack raises alarm and AI takeover concerns
  • Nate Soares warns this might be last warning
  • Author advocates technocratic approach with quantified estimates

AI Operating Model: Why Scaling AI Is an Organisational Design Problem

AI adoption is getting easier. Scaling AI is not. Models are more capable. APIs are easier to access. Copilots can be deployed quickly. Teams can prototype useful workflows in days.

  • AI scaling demands structured approach known as AI operating model.
  • AI operating model governs decision-making, funding, building, adoption, improvement.
  • Balances centralized and federated approaches for consistency and agility.

More from Tuesday 1 September →