← Back to Pull requests

osfs: Add zero-copy Bytes to mmap-backed files #243

Closed
unknown closed this pull request without merging on Oct 14, 2026 12:41 UTC
View on GitHub
unknown unknown commented on Oct 06, 2026 21:46 UTC
Author

WithMmap maps read-only files, but the mapping is only reachable through Read and ReadAt, which copy into the caller's buffer and synchronise with Close on every call. Consumers that parse large files in place, such as go-git's pack/idx/rev scanner, therefore carry their own mmap code that pulls the descriptor out of the billy.File, and that code cannot use files opened with WithMmap at all, as those expose no descriptor.

Add billy.BytesFile, an optional File interface discovered by type assertion like Locker and Syncer. Its Bytes() ([]byte, bool) returns the contents without copying, and reports false when they are not available in place, such as once the file is closed. The slice is valid until Close and must not be modified. The mmap-backed osfs file implements it by returning the mapping itself.

The chroot and mount wrappers embed billy.File, which hides every optional method of the wrapped file, and RootOS.Chroot wraps each file it opens. Both now forward Bytes, reporting false when the wrapped file does not implement it, so the interface survives the chroot go-git uses to reach its pack files.

This supersedes #226 by @pjbgf, which has the same goal. It differs in that the wrappers forward the method, which #226 leaves hidden behind a chroot; Bytes reports whether the contents are available, so a wrapper can always forward it; and there is no MmapCapability bit or Slice method. Whether a file provides its contents in place is decided per open, so only the type assertion on the returned file is reliable, and callers can slice the result of Bytes themselves.

Diff: 203 lines (+152 / -51) across 2 files Reviewer: pjbgf Review duration: 10974m
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 203 lines diff across 2 files
0.36
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.318
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #243"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 36.3% (MEDIUM) · Higher = larger blast radius
36.3%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 14.3% · Safe to merge
14.3%