Skip to content

Review summary: one schema for claim, points, excerpts, eye items and file notes - #1201

Merged
opencomputer-app[bot] merged 2 commits into
tracks-and-threadsfrom
fix/review-summary-contract
Nov 26, 2026
Merged

opencomputer-app[bot] merged 2 commits into
tracks-and-threadsfrom
fix/review-summary-contract

Conversation

@opencomputer-app

Copy link
Copy Markdown
Contributor

Requested by @igor Zalutski in Slack

Follow-up to #1192. Before this, review_summary took parts as z.record, review.save only checked that parts was an object, and the contract had no claim, points, excerpts, eye items or per-file notes (spec S9, R40, section 41).

One definition

  • sdks/typescript/src/computer/review.ts is the only definition of the summary: zod schemas ReviewSummary → ReviewParts → ReviewPart { title, claim, points?, files: [{ path, note? }], excerpts?: [{ path, side?, start, end, why? }], eye?: [{ text, path?, line? }] }. All objects are strict, with bounded sizes. Every field has a description written for the agent. The SDK now depends on zod.

  • computer (whose release bundle is computer/ only) and managed-agents (whose dist layout breaks if it imports outside src/) can't import the SDK. Each one gets a generated JSON Schema copy instead. npm run schema in sdks/typescript writes these files, and npm run schema -- --check checks them:

    • sdks/typescript/schema/review.v1.json
    • computer/schema/review.v1.json
    • services/managed-agents/src/org/review.v1.json

    A test in each of the three packages fails if its copy is out of date.

  • Org review.save validates { head, parts } against the schema using @cfworker/json-schema, which it already depended on. If the summary doesn't fit, it refuses with invalid_request and the path of the failing field.

  • Runner review_summary builds its input with z.fromJSONSchema from the copy, so the descriptions reach the agent. The tool description explains what makes a good summary. The handler PUTs the summary unchanged.

  • Surface Review.tsx checks the summary with ReviewSummary.safeParse. For each part it shows the claim, the points, excerpt cards (only the hunks the lines fall in, with the lines highlighted), eye items (gathered in the top box, each linking to its file in Full diff), and a file list with the agent's notes. It falls back to each file's first hunks only when the summary has no excerpts.

  • SDK fake review.save checks with the same schema. The scripted PR turn and the demo seed now save full summaries.

How zod is found

  • web: resolve.dedupe: ['zod'] in both vite configs and a paths entry in tsconfig. Web resolves its own zod from the SDK source even when sdks/typescript/node_modules is missing. I checked this with the SDK's zod moved aside: tsc -b, vitest and build:desktop all pass.
  • desktop: its typecheck and the fake-edge e2e import the SDK source through relative paths. desktop.yml now runs npm ci in sdks/typescript, and sdks/typescript/** is added to its paths.

Tests

  • SDK: the schema accepts a full summary and a minimal one, refuses bad ones, and the copies are current.
  • managed-agents: review.save refuses parts as an object, empty parts, the old note shape, start: 0 and an empty head. There is also a copy-equality test.
  • computer: the tool round trip through invoke(), refusal before any call, descriptions present in jsonSchema, and copy equality.
  • web: Review.test.tsx renders the Summary over a real surface and the fake server, and asserts the claim, points, eye item, file note and the marked excerpt hunk.

Redeploy: cloud (managed-agents), host bundle (computer), web.

… file notes

The summary's shape is a zod schema in the SDK (src/computer/review.ts). Org's
review.save validates with its JSON Schema copy, the runner's review_summary
tool takes its input schema from the same copy, and the surface parses with
the zod schema and renders each part's claim, points, excerpt hunks, eye
items and file notes, falling back to first hunks only without excerpts.
The app's CSP has no script-src, so zod's probe of new Function when a schema
is built was reported as a console error in the desktop e2e.
@opencomputer-app
opencomputer-app Bot merged commit d603a3b into tracks-and-threads Nov 26, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant