Before/after view of a change: include_hunks on changed_symbols/review_diff, read_code rev= (zero-fallback) #558

Closed
opened 2026-11-09 12:29:11 +01:00 by buildagent · 2 comments
Member

Part of the zero-fallback epic (#555). Cause 2: reviewing a change needs git show.

Observed

review_diff/changed_symbols say WHICH symbols changed (risk, test reach, freshness), but a reviewer needs WHAT changed. read_code serves only the working tree, so the lead reviewed every worker diff with git show (2026-11-09; operator: "do you use code-index???").

Proposal

  • changed_symbols/review_diff take include_hunks: true: the unified-diff hunk clipped to each changed symbol's span (base and head side), under the existing token budget, with hunks_truncated disclosed. A deleted symbol gets its base-side body.
  • read_code takes rev: "<commit-ish>": serves a path, range or symbol id as of that revision (base-side bytes from git; symbol spans from parsing the base-side file, which changed_symbols already does for classification).
  • A whole review then stays in code-index: review_diff(include_hunks) → find_callers on a finding → read_code(rev=base) for the old caller.

Acceptance

  • e2e: rename + body change + deletion in one diff → hunks per symbol; read_code(rev=base) returns the deleted symbol.
  • Benchmark task "review a diff" (sub-issue 1) needs zero shell calls.
  • Mutation: hunks not clipped to spans → the per-symbol test goes red.
Part of the zero-fallback epic (#555). Cause 2: **reviewing a change needs `git show`.** ## Observed `review_diff`/`changed_symbols` say WHICH symbols changed (risk, test reach, freshness), but a reviewer needs WHAT changed. `read_code` serves only the working tree, so the lead reviewed every worker diff with `git show` (2026-11-09; operator: "do you use code-index???"). ## Proposal - `changed_symbols`/`review_diff` take `include_hunks: true`: the unified-diff hunk clipped to each changed symbol's span (base and head side), under the existing token budget, with `hunks_truncated` disclosed. A deleted symbol gets its base-side body. - `read_code` takes `rev: "<commit-ish>"`: serves a path, range or symbol id as of that revision (base-side bytes from git; symbol spans from parsing the base-side file, which changed_symbols already does for classification). - A whole review then stays in code-index: `review_diff(include_hunks)` → `find_callers` on a finding → `read_code(rev=base)` for the old caller. ## Acceptance - e2e: rename + body change + deletion in one diff → hunks per symbol; `read_code(rev=base)` returns the deleted symbol. - Benchmark task "review a diff" (sub-issue 1) needs zero shell calls. - Mutation: hunks not clipped to spans → the per-symbol test goes red.
Author
Member

Done on branch codex-558 (de7bfc2a, 805492ef), merged into integration-1109 (ecbe801a).

  • read_code rev=<commit-ish>: path and range reads come from git through gitdiff::base_blob, under the same budget and total_lines contract. Refusals are typed: revision_symbol_unsupported, invalid_base_ref, revision_file_unavailable.
  • changed_symbols/review_diff include_hunks: each hunk is owned by the innermost changed symbol. Containers keep only their own lines and get hunk_in_children. The budget is spent leaves-first under the 4000-token cap, and omissions are disclosed. The default reply is byte-identical to before.
  • Wire: SourceSymbol.end_line defaults for old daemons. No new RPC was needed, and both legs are green. Six mutations were run.
  • The worker reported three "would have used #558 here" moments; after the rebuild, the new tool answered its own review.
Done on branch `codex-558` (`de7bfc2a`, `805492ef`), merged into `integration-1109` (`ecbe801a`). - `read_code rev=<commit-ish>`: path and range reads come from git through `gitdiff::base_blob`, under the same budget and `total_lines` contract. Refusals are typed: `revision_symbol_unsupported`, `invalid_base_ref`, `revision_file_unavailable`. - `changed_symbols`/`review_diff include_hunks`: each hunk is owned by the innermost changed symbol. Containers keep only their own lines and get `hunk_in_children`. The budget is spent leaves-first under the 4000-token cap, and omissions are disclosed. The default reply is byte-identical to before. - Wire: `SourceSymbol.end_line` defaults for old daemons. No new RPC was needed, and both legs are green. Six mutations were run. - The worker reported three "would have used #558 here" moments; after the rebuild, the new tool answered its own review.
Author
Member

Merged into #521.
mcp_smoke.rs::review_bytes_hunks_are_clipped_and_defaults_stay_unchanged grades hunks; revision_read_survives_removed_parent grades history.
Remaining: Review classification and hunks, including revision-by-symbol and zero-shell benchmark acceptance.

Merged into #521. mcp_smoke.rs::review_bytes_hunks_are_clipped_and_defaults_stay_unchanged grades hunks; revision_read_survives_removed_parent grades history. Remaining: Review classification and hunks, including revision-by-symbol and zero-shell benchmark acceptance.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
h-dv/code-index#558
No description provided.