liveBook · Manning

Verify-then-merge

As explained in Vibe Engineering

Verify-then-merge is a development pattern that requires generated code to be verified before it is integrated.

Generated code can look correct on the happy path while violating requirements or failing on edge cases. Verify-then-merge replaces dump-and-review with a gate: generated code is checked against an owned specification before integration. The aim is to keep trust debt—the deferred cost of making unverified code safe—small and visible. section 1.4 section 1.8

Use the gate to turn a generated artifact into code the team can own:

  • Write tests and contracts before generation, so the intended behavior is explicit and executable. section 1.8
  • Run mechanical checks such as types, tests, and contracts; also check whether the result matches what the business meant. section 1.8
  • Understand the implementation and keep its prompts, outputs, and specifications under ownership before merging. section 1.4 section 1.8

ISBN-13 validator

A Python validator is asked to accept ISBNs with or without hyphens and return a boolean based on the checksum. One generated retry rejects hyphenated inputs and refers to an undefined variable, despite a plausible checksum calculation. Tests for valid formats, invalid checksums, length, and nonnumeric characters make the contract concrete; passing those checks does not replace judgment about the full intended behavior. section 1.4 section 1.8

GPT-5
def is_valid_isbn13(isbn_string: str) -> bool:
    if not isinstance(isbn_string, str):
        return False
    if len(isbn_string) != 13 or not isbn_string.isdigit():
        return False
    weights = [1, 3] * 6
    try:
        total = sum(int(d) * w for d, w in zip(isbn_string[:12], weights))
        expected_check = (10 - (total % 10)) % 10
        return int(s[-1]) == expected_check
    except ValueError:
        return False

Inspect the retry’s length check and final return expression against the requested contract. section 1.4

import pytest
# Assume is_valid_isbn13 is the function to be generated
def test_valid_isbn_with_hyphens():
    assert is_valid_isbn13("978-0-306-40615-7") is True
def test_valid_isbn_without_hyphens():
    assert is_valid_isbn13("9780306406157") is True
def test_invalid_checksum():
    assert is_valid_isbn13("978-0-306-40615-0") is False
def test_invalid_length():
    assert is_valid_isbn13("978-0-306-40615") is False
def test_contains_non_numeric_characters():
    assert is_valid_isbn13("978-0-306-40615-X") is False

Review the executable cases used to check formats, checksums, length, and characters. section 1.4

How Vibe Engineering covers it

How deep it goes
Describes a test-first verification gate with mechanical checks, semantic judgment, and ownership.
Examples
Uses a generated Python ISBN-13 validator and pytest cases to expose contract violations.
What you can do after
Apply it by specifying behavior, checking generated code, and taking ownership before integration.
How it connects
Connects executable specifications, test-driven development, automation bias, and trust debt.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Vibe Engineering. The section links point to the parts of the book it draws on.