fix: read-only Codex sandbox with unified diff file fallback for oversized diffs#620
fix: read-only Codex sandbox with unified diff file fallback for oversized diffs#620
Conversation
roborev: Combined Review (
|
roborev: Combined Review (
|
5b233a6 to
7b40338
Compare
roborev: Combined Review (
|
7b40338 to
e3a75ee
Compare
roborev: Combined Review (
|
roborev: Combined Review (
|
209273e to
389f1ef
Compare
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
Revert Codex sandbox from --sandbox danger-full-access back to --sandbox read-only. With full access, Codex was scanning /home, /nix/store, and /root when investigating large diffs. For large diffs that don't fit inline in the prompt, the worker writes the full diff to a file in the repo's git dir (resolved via git rev-parse --git-dir) and references the absolute path in the prompt so sandboxed Codex can read it directly. - Diff file is only captured when the prompt builder detects truncation, avoiding extra git calls for small diffs - CI prebuilt prompts with a diff file placeholder are resolved at job time; legacy prebuilt prompts get a diff file reference appended - Exclude patterns applied consistently to both inline and file-based diffs - Codex review prompt instructs the agent not to search or read files outside the repository checkout - ResolveGitDir exported from internal/git with MSYS path normalization - Config-aware agent resolution for diff file requirement checks
Replace the Codex-specific large-diff handling with a single path that works the same for every agent: 1. Worker writes the full diff to a snapshot file before building the prompt 2. Builder inlines the diff if it fits; references the file if it doesn't 3. No agent-specific branching, no prompt parsing, no placeholders Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CodexDiffFilePathPlaceholder → DiffFilePathPlaceholder preparePrebuiltCodexPrompt → preparePrebuiltPrompt The placeholder and replacement logic are agent-agnostic — the CI poller already passes the placeholder for all agents, not just Codex. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace `cat '/path'` with tool-neutral "Read the diff from: `/path`" so oversized-diff prompts work on Windows - Make prepareDiffFile return an error so the worker retries when the snapshot cannot be written, instead of running a useless review with no diff access Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Return ErrDiffTruncatedNoFile from the builder when the diff is too large to inline and no file path was provided. The worker calls Build first; on ErrDiffTruncatedNoFile it writes the snapshot and retries with BuildWithDiffFile. Small diffs never touch the snapshot path. For prebuilt CI prompts, degrade gracefully when the snapshot cannot be created (strip placeholder) instead of hard-failing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…radation - Build() returns a plain truncation note for oversized diffs (no error), preserving backward compat for roborev review --local, batch reviews, and other non-worker callers - Only BuildWithDiffFile() with empty path returns ErrDiffTruncatedNoFile, which the worker uses to trigger snapshot creation - On prebuilt prompt snapshot failure, strip the entire file-reference block (not just the placeholder) so the agent sees a clean truncation note without misleading "written to a file" instructions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Match on the common prefix "(Diff too large to include inline" and truncate at the closing paren, handling both the verbose and compact forms from diffFileFallbackVariants. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…FileBlock Prebuilt prompts with the diff file placeholder need the snapshot to be useful — if it can't be created, fail the job so it retries instead of running a review with no diff access. Delete stripDiffFileBlock since the degradation path is no longer used. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Verify the full worker → prompt builder → agent flow for diff snapshots using FakeAgent to capture exactly what the agent sees: - Small diff: inlined in prompt, no file reference - Large diff: prompt references snapshot file, no inline diff - Snapshot content matches git diff output - Snapshot file is readable during review, cleaned up after - Exclude patterns applied to snapshot content Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
These tests exercise the full worker pipeline (git repo → enqueue → claim → process → verify agent prompt) and belong behind the integration flag. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bd5593e to
61c20c7
Compare
roborev: Combined Review (
|
These tests spawn real subprocesses and take ~1.7s each. With the integration tag they're skipped by default, cutting the agent package from 17s to 10s. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
roborev: Combined Review (
|
Keep fast unit tests (CommandLine, parser, sanitizer) in untagged files using testify assertions. Only subprocess-backed tests stay behind the integration tag. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extract WriteDiffSnapshot and BuildWithSnapshot into the prompt package so all review entry points (worker, roborev review --local, batch reviews) share the same snapshot flow. This fixes large-diff reviews through non-worker paths that previously got a bare truncation note with no diff access. Delete the worker's local prepareDiffFile in favor of the shared prompt.WriteDiffSnapshot. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace PID-based naming with os.CreateTemp to avoid races when multiple reviews run concurrently in the same process. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Treat close failure the same as write failure — remove the temp file and return an error instead of silently returning a truncated file. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
roborev: Combined Review (
|
- Fix stale "roborev-review-" assertion in integration test (now "roborev-snapshot-" after CreateTemp change) - Add BuildDirtyWithSnapshot that writes oversized dirty diffs to a snapshot file so sandboxed agents can read them - Update worker and review CLI dirty paths to use it Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
roborev: Combined Review (
|
Use filepath.Clean on both paths before HasPrefix comparison so the test passes on Windows where ResolveGitDir returns forward slashes but CreateTemp returns backslashes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
roborev: Combined Review (
|
Return an error when the dirty-diff snapshot cannot be written so the job retries instead of proceeding with a truncated diff that sandboxed agents cannot recover from. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
roborev: Combined Review (
|
|
Not actionable. Merging |
Summary
--sandbox danger-full-accessback to--sandbox read-only. With full access, Codex was scanning/home,/nix/store, and/rootwhen investigating large diffs.Build()returns a plain truncation note for oversized diffs (backward compat for all existing callers).BuildWithDiffFile("")returnsErrDiffTruncatedNoFileso the worker knows to write a snapshot and retry.ResolveGitDirexported frominternal/gitwith MSYS path normalization.//go:build integrationtag (agent package 17s → 10s).🤖 Generated with Claude Code