Vet Agent Patches: Pins, Fixtures & Flake Checks
In this article
This guide walks through vetting agent patches that touch pinned dependencies, test fixtures, and flake checks. You'll learn a repeatable review sequence that catches broken pins, fixture drift, and flaky-test landmines before they merge. You'll need a local clone of the target repository, the agent's patch (as a diff or branch), and the ability to run the project's test commands.
What You'll Need
- A local checkout of the repository on the base branch (usually
mainordevelop). - The agent's patch in unified diff format (from a PR,
git format-patch, or a branch you can fetch). - Access to the project's package manager (npm, pip, cargo, etc.) and test runner.
- Optional but helpful: a clean CI environment or Docker image that mirrors the project's test setup.
Step-by-Step
- Apply the patch to a clean branch. Create a new branch from the base commit, then apply the patch with
git apply --checkfirst to verify it applies cleanly. If it fails, ask the agent for a rebased patch. - Review the diff summary. Run
git diff --statto see which files changed. Flag any unexpected changes to lockfiles, fixture files, or test configuration—these are where hidden issues live. - Inspect pinned dependency changes. For each changed pin (in
package.json,requirements.txt,Cargo.lock, etc.):- Check the new version exists and is not a typo (e.g.,
1.2.3vs1.2.3.4). - Verify the version is compatible with the project's runtime (Node version, Python version, etc.).
- Look for known security advisories or breaking changes in the changelog.
- Check the new version exists and is not a typo (e.g.,
- Verify lockfile consistency. Run the package manager's install command (e.g.,
npm install,pip install -r requirements.txt) and check that the lockfile updates match the declared pins. If the lockfile is missing or stale, the patch is incomplete. - Review fixture changes. For each modified fixture file (JSON, YAML, SQL, etc.):
- Open the diff and confirm the changes are intentional and match the test expectations.
- Check for hard-coded paths, absolute timestamps, or machine-specific values that would break on another machine.
- Ensure the fixture is still referenced correctly by the tests (no orphaned files, no missing keys).
- Run the affected test suite. Execute the tests that use the changed fixtures or dependencies. For example:
pytest tests/test_fixture_handling.pyornpm test -- --grep "fixture". Confirm they pass locally. - Run the full test suite once. If the project's full suite is feasible locally, run it to catch cross-test interference. If not, run a representative subset that covers the modified areas.
- Check flake checks. Look for any new test annotations like
@pytest.mark.flaky,@flaky, or retry logic in the patch. Verify that the flake marker is justified—ideally the test has been run multiple times to confirm it's genuinely flaky, not just slow or timing-sensitive. - Run the flaky tests repeatedly. If the patch adds a flake marker, run that test 10–20 times locally (e.g.,
pytest test_x.py --count=20if pytest-repeat is available) to see if it fails consistently. A truly flaky test should fail intermittently, not always or never. - Verify the patch doesn't break other tests. Use
git stashto temporarily remove the patch, run the same tests, and compare results. This isolates whether the patch caused a regression or the test was already failing. - Check for environment-specific assumptions. Look for hard-coded paths like
/home/agent/, port numbers, or OS-specific commands. These will break in CI or for other developers. - Sign off or request changes. If everything passes, approve the patch. If not, provide specific, actionable feedback: list the exact files and lines that need changes, and suggest how to fix them.
Common Mistakes
- Ignoring lockfile drift: The patch updates
package.jsonbut notpackage-lock.json, causing CI failures. - Accepting fixture changes without running tests: A fixture might look fine in the diff but break a test that expects a specific key or value.
- Trusting the agent's test report: Always run tests yourself; the agent's environment may differ from yours.
- Overlooking flake markers on non-flaky tests: Marking a test as flaky when it's actually broken hides real bugs.
- Not checking for version compatibility: A dependency pin might be valid but require a newer runtime than the project uses.
Tips
- Use
git diff --word-difffor fixture files to see exactly which words changed, not just whole lines. - Run tests with
--tb=short(pytest) or--reporter=dot(Mocha) to get concise failure output. - If the patch adds a new dependency, run
npm auditorpip-auditto check for known vulnerabilities. - Keep a checklist of common pitfalls (lockfiles, fixtures, flake markers) and go through it for every patch.
- For flaky tests, run them in a loop with a timeout:
for i in {1..20}; do pytest test_flaky.py || break; doneto catch intermittent failures.
Troubleshooting
The patch doesn't apply cleanly. The base branch may have moved. Ask the agent to rebase the patch onto the latest main. If you need to apply it anyway, use git apply --3way to attempt a three-way merge, but be cautious—manual conflict resolution can introduce errors.
Tests fail after applying the patch, but the agent says they passed. First, verify you're on the correct base commit. Then check for environment differences: Node version, Python version, or missing system dependencies. Run npm ci or pip install -r requirements.txt to ensure your environment matches the lockfile. If tests still fail, it's likely a real regression—report it.
The lockfile is out of sync. Run the package manager's install command to regenerate it: npm install or pip install -r requirements.txt. If the lockfile changes significantly, the patch may have introduced unintended dependency updates. Review the diff carefully.
A flaky test fails every time you run it. That's not flaky—it's broken. Remove the flake marker and fix the underlying issue. Common causes: race conditions, unhandled async, or reliance on system time.
Fixture changes break tests that weren't in the diff. The fixture might be shared across multiple tests. Use git log --oneline -- to see its history and identify all tests that reference it. Run the entire test suite to be safe.
Frequently Asked Questions
Q: How do I know if a dependency pin is safe?
A: Check the version's release date and changelog. If it's a major version bump, look for breaking changes. Run the project's test suite with the new pin to see if anything breaks.
Q: What if the patch doesn't include a lockfile update?
A: That's a red flag. The lockfile ensures reproducible builds. Ask the agent to regenerate it and include it in the patch.
Q: Can I skip running the full test suite if the patch is small?
A: It's risky. Even small changes to fixtures or pins can have side effects. At minimum, run all tests that touch the modified files, and ideally run the full suite if it's fast enough.
Q: How many times should I run a flaky test to confirm it's flaky?
A: At least 10–20 times. If it fails less than 10% of the time, it's flaky. If it fails more, it's likely a real bug.
Q: What should I do if the patch modifies a fixture but the tests still pass?
A: That's fine, but double-check that the fixture change is intentional. Sometimes agents update fixtures to match new code, but accidentally change a value that was correct.
Q: The patch adds a retry mechanism for tests. Is that okay?
A: Retries can mask flakiness, but they're acceptable if the flakiness is due to external services or timing. However, the retry logic should be limited and well-documented. If the test fails consistently even with retries, it's broken.