Skip to content
Agent Field Notes
Course contentsExpand a topic to choose a lesson.

SYSTEMATIC LEARNING / FOUR-LEVEL COURSE

Bind code changes to acceptance evidence

Examine code base understanding, isolation execution, acceptance, regression and manual review.

Learning objectives: Evidence of code delivery must be bound to the actual commit and environment. Acceptance goals are determined by tasks and protected constraints, and the Agent cannot make a change appear complete by deleting tests, hiding failures, or reusing old results.

Content checked: 2026-10-03 · Each level has independent explanations, tasks and inspections

Choose a starting point based on your familiarity with this topic. Current level: Debugging · Diagnose failures. After completing the task, continue to the next level. Reading and self-checks alone do not establish mastery.

On this level

Review the prerequisites

Suitable for: Backend developers learning Agent applications.

Bind code changes to acceptance evidence
Evidence of code delivery must be bound to the actual commit and environment. Acceptance goals are determined by tasks and protected constraints, and the Agent cannot make a change appear complete by deleting tests, hiding failures, or reusing old results.

How does the mechanism work?

Step-by-step explanation
  1. Is the Agent complete after deleting the failed test?

    Task completion requires protecting acceptance criteria from changes by the executor.

  2. How to distinguish regression when existing tests fail?

    Existing systems often have failures, so use a fair before-and-after comparison.

  3. Can the previous test results be reused after modification?

    Acceptance evidence applies to a specific version; later changes may invalidate it.

Debugging · Diagnose failures

Diagnose failures · Bind code changes to acceptance evidence

Objectives of this level: Repair stale evidence binding and show an actual Java red/green regression.

Visual guide · Bind delivery to the changed source

Bind delivery to the changed source

A green result from an old revision cannot accept a new patch. The local evidence function is separate from actual Java source, build and regression execution. Select the figure to open it at full size.

Same after-sales project

A coding Agent proposes a Java refund-deduplication patch. Changed paths, source revision and actually executed build/regression records must align. The Python function below evaluates a local evidence contract only; passing it cannot replace a Java source/build delivery or a target JD’s Java language requirement.

The existing capstone main-return creates a return application; it does not execute a refund. These manifests are independent fictional extensions or policy/evidence/counting exercises. They do not add real refunds, publication, model calls or Java execution to the capstone runtime.

Same-input fault reproduction

In your evidence function copy accept any successful build regardless of revision. The same stale-build payload then passes incorrectly; locate evidence-version binding before investigating Java logic. Repair it and retain the bool-exit and latest-current-fails controls. Separately run the Java baseline below, implement your own minimal deduplication change, and retain red→green raw build/test logs bound to your source hash.

{
  "revision": "r2",
  "allowed_paths": [
    "src/AfterSalesReceipt.java"
  ],
  "changed_paths": [
    "src/AfterSalesReceipt.java"
  ],
  "events": [
    {
      "kind": "build",
      "revision": "r1",
      "executed": true,
      "exit_code": 0
    },
    {
      "kind": "regression",
      "revision": "r2",
      "executed": true,
      "exit_code": 0
    }
  ],
  "baseline_exit": 1
}

Use this expected result from the foundation sample, unchanged:

{
  "expected": {
    "delivery": "review_only",
    "reasons": [
      "build_not_executed"
    ]
  },
  "error": null
}

Evidence before repair

After implementing, preserve a faulty student-before.py. Run the before command, inspect its first actual mismatch, then repair student.py and rerun the after command. Keep both reports, source hashes/diff, an evidence→hypothesis→distinguishing-evidence note and the named negative control. Reports may contain an earlier first mismatch than the named probe; explain both. The public suggested fault is a reproducible exercise, not an unannounced incident or unseen test.

python3 lab_runner.py grade --course java-coding-agent-design --module student-before.py --out before-report.json
python3 lab_runner.py grade --course java-coding-agent-design --module student.py --out report.json
import json
from pathlib import Path
report = json.loads(Path("before-report.json").read_text())
first = next((row for row in report["checks"] if not row["passed"]), None)
print(json.dumps(first, indent=2, ensure_ascii=False))

Optional retrospective after evidence

It violates the not-executed null protocol; reject, then inspect genuine raw logs.

Same Java baseline and commands

Continue from implementation, or save the exact baseline below as src/AfterSalesReceipt.java after creating src. A JDK with javac/java is required; if unavailable, record Java execution pending. Compilation is expected to exit 0; this unchanged program is expected to exit 1 with duplicate_refund. Preserve the faulty source before your own repair and rerun these same commands afterward. Actual Java source/hash/raw outputs are separate from the simulated Python evidence metadata.

import java.util.HashSet;
import java.util.Set;

public class AfterSalesReceipt {
    private int refunds = 0;
    private final Set<String> seen = new HashSet<>();
    public void apply(String operationKey) {
        refunds++; // Deliberately broken baseline: no duplicate guard.
    }
    public static void main(String[] args) {
        AfterSalesReceipt service = new AfterSalesReceipt();
        service.apply("refund-42");
        service.apply("refund-42");
        if (service.refunds != 1) throw new AssertionError("duplicate_refund");
        System.out.println("one_refund");
    }
}
javac src/AfterSalesReceipt.java
java -cp src AfterSalesReceipt

code example

Preserve the same-input red/green repair

In your evidence function copy accept any successful build regardless of revision. The same stale-build payload then passes incorrectly; locate evidence-version binding before investigating Java logic. Repair it and retain the bool-exit and latest-current-fails controls. Separately run the Java baseline below, implement your own minimal deduplication change, and retain red→green raw build/test logs bound to your source hash.

Acceptance task for this level

Freeze a faulty copy, submit evidence and competing hypotheses, reproduce the same-input failure, repair it and preserve red/green reports plus a negative control. Contract: assess_patch_delivery(payload).

Acceptance self-checks

Reading this browser’s record…

Hide the answer and check your understanding

What if Java compilation never ran but exit_code is 0?

Further explanations and practice

When encountering unfamiliar principles, first read the implementation, continuous questioning and migration cases, and then independently explain the premise and boundaries. Answers and notes are saved to the original account record.

All linked explanations and exercises (1 )

Sources and verification scope

The principles are based on public information; the numbers, cases and tasks are the teaching design of this website. Offline experiments verify the range noted on this page, and the learning effect still needs to be judged through independent tasks and feedback.