Here's my read of PR #799. The PR's framing oversells the severity ("critical OS-level, OOM, security risks") — most are theoretical hardening with weak attack vectors, and at least one fix would break an existing test contract. A couple are worth cherry-picking; the rest aren't.
Per-fix verdict
1. opencode — move session dir from /tmp to .git/entire-opencode/
Partially valid. On Linux, /tmp is a shared sticky-bit dir; another local user could pre-create entire-opencode/<your-sanitized-repo-path>/ as a symlink and squat the path. On macOS os.TempDir() is $TMPDIR which is per-user (/var/folders/.../T/), so the concern is much weaker.
- Worth fixing, but
.git/entire-opencode/ is an unusual place — .git/ is git-managed territory. .entire/ or .git/entire/opencode/ (under an existing entire namespace) might fit conventions better. Worth discussing with the team before porting.
2. git_operations.go — batch git fetch by 500 hashes
Real but extreme edge case, and the patch location is now stale. Linux ARG_MAX is typically ~2MB; at 41 bytes/hash that's ~51k hashes before exhaustion. Since the PR was opened, FetchBlobsByHash was refactored to delegate to checkpoint/remote.FetchBlobs (cmd/entire/cli/checkpoint/remote/git.go:85), which now uses git fetch-pack and still passes every hash as an argv entry — so the same ceiling applies there. If we believe fetches of ≥50k checkpoint blobs are realistic for big repos, port the batching idea into remote.FetchBlobs.
3. redact/pii.go — deep-copy maps in getPIIConfig()
Mostly invalid as written. ConfigurePII does cfgCopy := cfg and stores a fresh pointer; the maps inside are never mutated after assignment. A reader that already holds the old *PIIConfig can safely range over its maps even while a new ConfigurePII runs — they're different map headers. The real (theoretical) hazard is a caller who mutates the map they passed in after calling ConfigurePII; the right defense is to deep-copy in ConfigurePII once, not on every read. Don't apply this one as-is.
4. utils.go — os.ReadFile → io.Copy
Strict improvement, OOM framing is overblown. copyFile is called from metadata.go:103 and rewind.go:678 with transcripts — the API body cap is 16 MiB (commit 0b9fa0a64), so we're reading ≤16 MiB into RAM, not "massive transcripts". No real OOM risk, but streaming is the right pattern. Note the patch drops the osroot.WriteFile helper in favor of root.OpenFile directly — functionally equivalent. Low-risk to apply.
5. session/state.go — Lstat after rename, error if symlink
Invalid. os.Rename(tmpFile, stateFile) of a regular file replaces the destination atomically; the result is always a regular file. Session IDs are already validated by validation.ValidateSessionID before path construction. The post-rename Lstat defends against a scenario that can't occur. Don't apply.
6. gemini.go + opencode.go — error if single message > maxSize
Don't apply — breaks an existing test. geminicli/gemini_test.go:582 TestChunkTranscript_SingleOversizedMessage explicitly asserts that a single message larger than maxSize returns one oversized chunk with err == nil. That's the current contract ("can't split a single message"). The PR's return nil, fmt.Errorf("single message size...") would fail this test and break checkpoint saving for any session containing one large message. If we want to change the contract, that needs a separate design discussion.
7. claude.go — bufio.Reader.ReadBytes → fixed 32K buffer + 10 MiB line cap
Not actually included in the PR description but is the biggest change (57+/22-). bufio.Reader.ReadBytes does grow its internal buffer unboundedly, so a pathological 1 GiB single line would balloon RAM. In practice Claude transcript lines are bounded by the API response cap, which we just raised to 16 MiB. The PR caps lines at 10 MiB and silently skips the rest — that would now drop legitimately-large messages. If we want this hardening, the cap should be ≥16 MiB and probably surface a warning, not silently truncate. Also: the existing Copilot review correctly flagged that this rewrite has zero unit tests for GetTranscriptPosition / ExtractModifiedFilesFromOffset edge cases (EOF without trailing newline, offset boundaries).
Recommendation
Worth porting (with adjustments):
- #4 streaming
copyFile — apply as-is, modulo rebasing on current code.
- #1 opencode session dir — apply, but bikeshed the destination (
.git/entire-opencode/ vs .entire/opencode/) with the team.
- #2 ARG_MAX batching — only if we expect ≥50k-hash fetches; port into
remote.FetchBlobs not the old call site.
Skip:
- #3 PII deep-copy on read — wrong layer; if we care, fix
ConfigurePII to deep-copy inputs.
- #5 post-rename Lstat — doesn't defend against anything reachable.
- #6 chunk oversized-message error — breaks an existing test contract.
- #7 fixed-buffer Claude reader — would silently drop ≤16 MiB legit lines; needs redesign + tests.
Want me to open a small PR with just #4 (and maybe #1) cherry-picked and rebased?