CodeRigor

LESSON

Deliver the fix with a replayable review trail

Combine a reviewed diff, current checks and sealed acceptance into an explained handoff.

Bring the pieces together: a bounded owner task, selected context, a proposed diff, independently collected checks and a final explanation. The replay has three authored proposals: round the float, change a test expectation, and replace float parsing with a strict integer implementation.

Only the last proposal should be accepted. The downloadable lab applies each bundled proposal to a newly owned temporary Git fixture, records the actual diff and runs checks. It never accepts an arbitrary patch path or repository argument. A live agent is an optional source of a proposal; the owner’s review obligations stay the same.

A reproducible owner handoff
start / 3
Only the scoped candidate with current observed checks and sealed acceptance is accepted.
A reproducible owner handoff
Only the scoped candidate with current observed checks and sealed acceptance is accepted.

Run python -I replay.py from the extracted lab. The core run uses unit and syntax checks; add --quality after installing the pinned tools to require formatting and mypy too. The command prints a JSON review trail and can write an output receipt in an explicitly new owned directory. Temporary repositories are removed automatically.

The initial baseline reproduces the failure. The rounding proposal remains rejected by grammar cases. The test-edit proposal is refused before checks because it changes a file outside scope. The integer proposal passes the current checks and sealed acceptance. These are actual fixture outcomes, not a transcript of a live model session.

Python
import re


def parse_cents(text: str) -> int:
    """Parse the lab's canonical signed two-decimal amount without floats."""
    if not isinstance(text, str):
        raise ValueError("amount must be text")
    match = re.fullmatch(r"(-?)(0|[1-9][0-9]{0,8})\.([0-9]{2})", text)
    if match is None:
        raise ValueError("amount is outside the canonical decimal grammar")
    magnitude = int(match.group(2)) * 100 + int(match.group(3))
    return -magnitude if match.group(1) else magnitude
from collections.abc import Callable

VALID_CASES = (("zero", "0.00", 0), ("fraction", "0.29", 29),
               ("negative", "-0.29", -29), ("whole", "12.34", 1234),
               ("negative_zero", "-0.00", 0), ("limit", "999999999.99", 99999999999))
INVALID_CASES = (("exponent", "1e2"), ("spaces", " 1.00"), ("plus", "+1.00"),
                 ("leading_zero", "01.00"), ("fraction_digits", "1.2"),
                 ("unicode_digits", "1.00"), ("nonfinite", "NaN"),
                 ("type", 1.00), ("oversize", "1000000000.00"))

def run_acceptance(candidate: Callable[[str], int]):
    """Known in-process lab candidates only; this is not an arbitrary-code sandbox."""
    failures = []
    for name, text, expected in VALID_CASES:
        try:
            actual = candidate(text)
        except Exception:
            failures.append(name)
        else:
            if type(actual) is not int or actual != expected:
                failures.append(name)
    for name, value in INVALID_CASES:
        try:
            candidate(value)
        except ValueError:
            pass
        except Exception:
            failures.append(name)
        else:
            failures.append(name)
    return failures

print("reference failures", run_acceptance(parse_cents))
print("rounding failures", run_acceptance(lambda text: round(float(text)*100)))

The final pure review function assumes its candidate and observations were bound by the trusted collector. It cannot authenticate arbitrary caller objects. The local collector loads only bundled known code, hashes source plus sealed tests and records real subprocess results; that is the boundary of the demonstrated evidence.

The final explanation should state the old float/truncation cause, the canonical grammar, integer arithmetic, files changed, checks actually run and any checks omitted. Passing this small lab does not certify an arbitrary agent or application, and it does not require outsourcing ownership of the change.

Inspect the boundary
start / 3
Only the scoped candidate with current observed checks and sealed acceptance is accepted.
Inspect the boundary
Only the scoped candidate with current observed checks and sealed acceptance is accepted.
Python
receipts = [{"candidate":"rounding", "acceptance":False, "scope":True},
            {"candidate":"test edit", "acceptance":False, "scope":False},
            {"candidate":"integer", "acceptance":True, "scope":True}]
for item in receipts:
    accepted = item["acceptance"] and item["scope"]
    print(item["candidate"], "accept" if accepted else "reject")

Run the complete replay and inspect its actual diff, check vectors, exit codes, failure labels and final decision. Use the supplied starter to improve your own task or add an independently chosen boundary test. Optional live-agent work should reuse the task and owner checks; never paste secrets or treat an agent’s summary as a test receipt.

Cleanup is explicit: the replay removes its temporary fixture repositories; remove only the output receipt directory you created and the lab’s own virtual environment. No remote, deployment, account or production database is used.

Download the complete lab. The archive includes runnable code, tests, fixtures and a README.

Authored proposals · Actual collected checks

A plausible patch still needs evidence.

Choose a bundled proposal to inspect its real Git diff and observed checks. This is an offline teaching replay, with no live model session. The owner’s final task permits changes only to money.py.

Reject this proposalrounding

1 · Actual observed checks

  • failed
    unitpython -I acceptance_runner.pyObserved exit 1
  • passed
    syntaxpython -I syntax_check.pyObserved exit 0
  • passed
    formatruff format --check money.pyObserved exit 0
  • passed
    typemypy --strict money.pyObserved exit 0
Source and sealed-test snapshotde2089e0cdc68fe40f443d6f1333e12de19fb3ad1a378424afad64f2d4dbde8a

A digest identifies bytes. It does not authenticate arbitrary agent claims.

2 · Review findings

  • acceptance:exponent
  • acceptance:fraction_digits
  • acceptance:leading_zero
  • acceptance:oversize
  • acceptance:plus
  • acceptance:spaces
  • acceptance:type
  • acceptance:unicode_digits
  • failed:unit
  • float_remains:money.py

3 · The real Git diff

Diff
diff --git a/money.py b/money.py
index 98feda2..2605956 100644
--- a/money.py
+++ b/money.py
@@ -1,2 +1,2 @@
 def parse_cents(text: str) -> int:
-    return int(float(text) * 100)
+    return round(float(text) * 100)
Download the task, proposals, collector, checks and replay →

Watch & read

Free lectures, talks and readings that cover this skill from another angle. All resources →