Urgent.News

What's breaking now, across thousands of outlets.

Tech

Two Commits per Refactor: A Diff Gate That Keeps Pins Away From the Move

Most messy-repo refactors fail at review, not at runtime. The riskiest commit is the one that edits tests and production code together. Once that happens, nobody can tell a broken pin from a broken move. Characterization tests answer one question: does behavior match today? That answer is only trustworthy if the pins stand alone. Mixed diffs destroy that independence. Enforce the split with a…

Refactoring messy repositories often stumbles during review rather than at execution. The most perilous commit is the one that intertwines test files with production code. This makes it impossible to distinguish between defective pins and faulty moves. Characterization tests serve a single purpose: verifying that behavior remains consistent.

This reliability hinges on keeping pins separate from moves. To enforce this separation, a script rather than human discipline should be employed. Step 1 involves defining which paths are pins and which are moves; a machine-readable map of the repository is required. Ambiguity can bring the gate to a halt. A minimal configuration file at the repository root is necessary to clarify this distinction.

The config file consists of three categories: test_globs, code_globs, and neutral_globs. Anything not fitting into these categories is considered an error, not a silent pass. A key point to note is that Python's fnmatch function allows '*' to match across directory boundaries. Consequently, tests/** includes all files within the 'tests' directory, which differs from gitignore syntax.

It is crucial not to presume that teammates interpret the globs in the same manner as the script author. Step 2 entails classifying each commit diff according to the aforementioned categories. This script is a proposed pattern, not a pre-existing tool. It is concise enough to be manually reviewed line by line. The script is named split_gate.py and can be invoked with a revision range, defaulting to the last commit (HEAD~1..HEAD).

The script will exit with different codes depending on the outcome: 0 for a clean commit, 1 for a mixed commit, 2 for an unclassified path, or 3 for a git error.

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

Principles of Anchor Engineering

  • Anchor Engineering shifts focus to human judgment in AI-driven development
  • Anchors are high-level design decisions guiding AI code implementation
  • Shared "Anchor Book" ensures team alignment and reduces inefficiencies

Order Is a Hidden Input: Permutation-Sweeping an Agent-Patched Test Suite

An agent patch can pass your entire suite in the default order and still be order-coupled. The green run proves the suite works in one sequence, not that the tests are independent.

  • Order is a hidden input in agent-patched test suites
  • Patch stability depends on default code order, not just affected code
  • Stateful suite reveals order-coupled issues from caches and side effects

48-Hour Field Notes: My Batch Job Trusted Local Disk, and a Restart Re-Bought Every Token

48-Hour Field Notes: My Batch Job Trusted Local Disk, and a Restart Re-Bought Every Token I had a batch job that walked a queue of documents, called a model for each one, and wrote a summary into an…

  • Batch job processed five documents serially in first six hours
  • Restart caused duplicate processing due to reliance on local disk
  • Receipts table and idemkey function solved repeated work issue

More from Saturday 17 October →