eden/.llms/rules/ACR_unscoped_hook_fetch.md
Severity: CRITICAL
sl diff, sl prefetch, hg cat, or similar operations between arbitrary commits without scoping to specific filessl diff SRC DEST without --include or path argumentssl prefetch or hg prefetch without explicit path scope in a hook contextnumber_of_changed_files(src, dest) without a cap--include 'path:specific/dir')prefetch --max-size 100MB)BAD (unscoped diff in merge driver — matches S617619):
# merge_driver.py — runs during every rebase
def resolve_conflicts(source_rev, dest_rev):
# Gets ALL changed files between source and dest — not just conflicting ones!
diff_output = subprocess.check_output(["sl", "diff", "-r", source_rev, "-r", dest_rev])
# For a cross-branch rebase this can be millions of files.
# Each file triggers an LFS prefetch. 5x traffic spike ensued.
for changed_file in parse_diff(diff_output):
fetch_and_merge(changed_file)
GOOD (scoped to conflicts only):
def resolve_conflicts(source_rev, dest_rev, conflict_files):
# Only process the specific files that have merge conflicts
for path in conflict_files:
src_content = subprocess.check_output(["sl", "cat", "-r", source_rev, path])
dst_content = subprocess.check_output(["sl", "cat", "-r", dest_rev, path])
resolve_file(path, src_content, dst_content)
BAD (no size limit on fetch):
async fn fetch_file_content(repo: &Repo, cs_id: ChangesetId, path: &Path) -> Result<Bytes> {
let content = repo.get_file_content(cs_id, path).await?;
Ok(content) // What if this file is 24GB? OOM.
}
GOOD (size-limited):
const MAX_FETCH_SIZE: u64 = 100 * 1024 * 1024; // 100MB
async fn fetch_file_content(repo: &Repo, cs_id: ChangesetId, path: &Path) -> Result<Bytes> {
let metadata = repo.get_file_metadata(cs_id, path).await?;
if metadata.size > MAX_FETCH_SIZE {
bail!("File {} is {} bytes, exceeds limit of {}", path, metadata.size, MAX_FETCH_SIZE);
}
repo.get_file_content(cs_id, path).await
}
Hooks and merge drivers must explicitly scope their operations to only the files involved in the conflict or hook trigger — never diff or prefetch across the full commit range. Add per-request size limits for file content fetches (recommend 100MB default). For LFS, enforce a per-sync bandwidth budget. Test hooks with large cross-branch rebases to verify they don't cause traffic amplification.
sl diff between rebase source and destination without file scoping. Triggered sl prefetch for all changed files, causing sustained 5x LFS traffic increase and OOM-based load shedding. Recurred as S619192.