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
- Is the Agent complete after deleting the failed test?
Task completion requires protecting acceptance criteria from changes by the executor.
- How to distinguish regression when existing tests fail?
Existing systems often have failures, so use a fair before-and-after comparison.
- Can the previous test results be reused after modification?
Acceptance evidence applies to a specific version; later changes may invalidate it.
Implementation · Build it
Implement the contract · Bind code changes to acceptance evidence
Objectives of this level: Implement the evidence filter and independently deliver Java source/build work.
Visual guide · 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.
Complete function contract
Implement assess_patch_delivery(payload). revision is nonempty; allowed_paths and changed_paths are unique nonempty string lists. Paths must be relative forward-slash paths with no empty, dot or dot-dot segments and no backslash; invalid paths raise ValueError:input. events is a list of records: kind build/regression; nonempty revision; real bool executed; if executed, exit_code is an integer (negative allowed, bool invalid), otherwise exit_code must be null. baseline_exit is integer or null, never bool. Missing/malformed fields raise ValueError:input; extras ignored, empty lists valid. Return exactly delivery/reasons. Any changed path outside allowed_paths → blocked with sorted outside_scope:<path> reasons, ignoring later policy reasons. Otherwise add no_java_change if no changed path ends .java. For each build/regression take the LAST event whose revision matches payload.revision; missing/not executed → <kind>_not_executed, nonzero → <kind>_failed. baseline null → baseline_missing, 0 → baseline_not_red. Sort reasons ascending. Nonempty reasons → review_only; empty → evidence_complete. This label means fixture metadata is complete, not genuine execution, semantic correctness or a production-safe patch.
Every listed input key must exist; explicit null is not an absent key. All returns must be JSON-compatible fresh containers, with exact bool/int distinctions, and leave the input unchanged. Every invalid declared field uses exactly ValueError("input"); this includes malformed nested fields. Do not swallow NotImplementedError or return a self-declared passed flag.
Own blank implementation
Download the full local package, extract it and work in its lab_runner.py directory. Runner and this case manifest are alternatives: save the runner and cases/java-coding-agent-design.json with that exact directory layout. The manifest contains all public fixed inputs/expected outputs; it contains no general solution. It is not an unseen assessment. Python 3.9+ and standard library only; no model keys or network calls are needed while grading.
def assess_patch_delivery(payload):
raise NotImplementedError("Implement the documented contract yourself")
python3 lab_runner.py scaffold --course java-coding-agent-design --out student.py
python3 lab_runner.py grade --course java-coding-agent-design --module student.py --out report.json
The untouched scaffold must exit 1. Fill the function yourself and rerun; all 13 public checks must pass for exit 0. Submit student.py, the generated report.json, your source diff and one additional condition-changing test. The runner imports and calls your function on each actual payload, compares exact output/error, checks input preservation and container independence, and records runner/cases/student SHA. A manual passed flag is not accepted. Its 5-second process timeout is a hang guard, not an enterprise latency requirement.
Separate real Java delivery
Save this deliberately broken source as src/AfterSalesReceipt.java. Create src first. A JDK with javac/java is an additional prerequisite. Compilation is expected to exit 0; the unchanged program is expected to exit 1 with duplicate_refund. Implement your own deduplication fix; retain the actual source SHA, commands and raw red/green logs. The provided baseline is sequential only; concurrency and database persistence are separate tasks, not already implemented.
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
Deliver your own function and report
Implement assess_patch_delivery(payload). revision is nonempty; allowed_paths and changed_paths are unique nonempty string lists. Paths must be relative forward-slash paths with no empty, dot or dot-dot segments and no backslash; invalid paths raise ValueError:input. events is a list of records: kind build/regression; nonempty revision; real bool executed; if executed, exit_code is an integer (negative allowed, bool invalid), otherwise exit_code must be null. baseline_exit is integer or null, never bool. Missing/malformed fields raise ValueError:input; extras ignored, empty lists valid. Return exactly delivery/reasons. Any changed path outside allowed_paths → blocked with sorted outside_scope:<path> reasons, ignoring later policy reasons. Otherwise add no_java_change if no changed path ends .java. For each build/regression take the LAST event whose revision matches payload.revision; missing/not executed → <kind>_not_executed, nonzero → <kind>_failed. baseline null → baseline_missing, 0 → baseline_not_red. Sort reasons ascending. Nonempty reasons → review_only; empty → evidence_complete. This label means fixture metadata is complete, not genuine execution, semantic correctness or a production-safe patch.
The exact function and complete inputs are in the main body. Implement from the blank starter, not by copying expected outputs into branches.
Acceptance task for this level
Implement the blank function and submit the real generated report, own code/diff and one changed-condition test; Java candidates additionally deliver their real Java patch/build. Contract: assess_patch_delivery(payload).
Reading this browser’s record…
Hide the answer and check your understanding
Which build record applies when r2 was tested twice?
Expand reference derivation
Use the last current-revision event, including a later failure.
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.