Repository navigation
feat(workspace): support comparison-side code access - #1915
Conversation
|
🔍 OpenCodeReview found 2 issue(s) in this PR.
|
| resolution, _ := p.ResolveWorkspaceComparison(ctx) | ||
| return resolution |
There was a problem hiding this comment.
Bug: The error from ResolveWorkspaceComparison is silently discarded. While ResolveInput documents that it never returns an error, the previous workspace implementation (resolveCommit("HEAD")) could only "fail" by returning an empty string when HEAD doesn't exist — a benign case. The new ResolveWorkspaceComparison can fail for other reasons (e.g., git binary not found, permission errors, repository corruption), and those failures are now silently swallowed.
This matters because ResolveInput is called in agent.go to populate a.inputResolution for the run manifest. If ResolveWorkspaceComparison fails transiently here but succeeds later during GetDiffSet → workspaceTrackedDiff, the manifest will record empty/zero endpoints while the diff was generated against a real base — an inconsistency that could mislead downstream consumers of the manifest.
Consider logging the error or restructuring so the resolution is performed once and reused consistently.
| if current.Mode != ModeWorkspace || current.Ref != "" { | ||
| return nil, fmt.Errorf("workspace code access requires a live working tree") | ||
| } | ||
| if (previous.Mode != ModeCommit || previous.Ref == "") && (previous.Mode != ModeEmpty || previous.Ref != "") { |
There was a problem hiding this comment.
This compound boolean expression is correct but hard to read and verify. It uses a double-negation structure ((NOT valid-commit) AND (NOT valid-empty)) that requires careful mental evaluation of each sub-condition.
Consider extracting the validity checks into named variables for clarity and consistency with how NewComparisonCodeAccess structures its validation:
validCommit := previous.Mode == ModeCommit && previous.Ref != ""
validEmpty := previous.Mode == ModeEmpty && previous.Ref == ""
if !validCommit && !validEmpty {
return nil, fmt.Errorf("workspace code access requires a pinned base or an empty tree")
}This makes each accepted state explicit and reduces the risk of future modification errors.
|
lgtm |
Description
Extend the comparison-side tools introduced in #1903 to workspace reviews.
side: "old" | "new"tofile_read,code_search, andfile_find. The default/new side retains its existing output and reads the live working tree; the old side reads HEAD frozen at initialization, not HEAD's parent.The new side is deliberately not snapshotted. Workspace resume remains unsupported. This changes the previous staged fallback behavior rather than adding a staged-only review mode.
Type of Change
How Has This Been Tested?
make checkmake test(full suite, including the race detector)make coverage(91.6% total coverage; 90% required)ocr review --audience agent --background "..." --format json: completed all 8 selected source files with no comments and no failed files.No model-quality benchmark was run for this change.
Checklist
AI/LLM Disclosure
Implementation and test/documentation preparation used OpenAI Codex with
gpt-6-astra. The pre-commit review used OpenCodeReview v1.13.8 withgpt-6-astraviaidealab-responses. No AI attribution or co-author trailers are included in the commit.Related Issues
Follow-up to #1903.