Part 4 — Build the Harness Chapter 17
AI-Assisted Code Review
In this chapter
Bring the evidence to the reviewer
The registration contract can pass while a name at the exact length limit is rejected. You have the lab-review branch and the patch from Custom Agents & Sub-Agents. Check the contract yourself before opening the review.
git log -1 --oneline
npm test
npm run test:registration
git diff lab-registration lab-review -- src/app.ts
Both suites should pass. The test data covers a short name and a name of 101 characters. The spec also accepts 100. Ask your reviewer for a request that follows the spec and behaves differently at the changed line.
Read specs/registration-validation.md, contracts/registration.test.ts,
and notes/review.patch. Find a criterion the existing tests could miss.
For each finding, give the changed file and line, a concrete input,
the expected result, and what the code implies will happen. Identify
the checks you actually ran.
Verify a finding before asking for a fix
Start npm start in one terminal. From a second terminal, submit names of three lengths to the local service. The Node script builds the JSON bodies so you can see exactly which input produced each status.
node --input-type=module - <<'JS'
for (const length of [99, 100, 101]) {
const response = await fetch("http://127.0.0.1:3000/registrations", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ name: "x".repeat(length), email: "sam@example.test" }),
});
console.log(length, response.status);
}
JS
On lab-review, the statuses are 201, 400 and 400. The middle case should return 201. A model that reports this as an observed result without running the request has given you a hypothesis. Preserve the distinction in your notes.
Turn the 100-character case into an HTTP regression test in test/app.test.ts and run npm test to see it fail. Then ask Build for the smallest change that makes the test pass without rejecting a different set of inputs. Review the new diff and run both suites. The direct requests should now return 201, 201 and 400. Stop the service and keep the base, head, verified finding and resolution together in your review note.
If the review returns no findings, check whether the session opened the spec and the materialized diff. Repeat with the criterion and input specified. The decision to accept the patch stays with the person who can reproduce the behavior.
References
- OpenCode maintainers. Agents. Official OpenCode 2 documentation for separate review sessions.
- Node.js contributors. Test runner. Node.js API reference.