Repository navigation
fix(sandbox): the collision warning names its winner when layers are copied - #3480
bryan-minimal wants to merge 1 commit into
Conversation
…copied The warning for a path two rootfs layers ship with different contents names the layer whose file stays by the inode the assembled path carries. With the cache and the rootfs on different filesystems the link pass copies each file, a copy has an inode of its own, and the warning said `winner = "unknown"` every time. The first-linked file stays, so the winner of a copied file is the first layer, in link order, that ships the path. That layer is named when its file agrees with the placed one by the link pass's own comparison, and the winner stays unknown when it does not, since the placed file then came from somewhere other than the layers. Refs gominimal/inbox#1226 Co-Authored-By: Claude <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Reviewed: 1 finding, none blocking at Address the comments on the diff. Clobber: none seen. |
| let is_the_copy = fs::symlink_metadata(&shipped).is_ok_and(|m| m.is_file()) | ||
| && matches!( | ||
| common::link_collision(&shipped, &at), | ||
| common::LinkCollision::Same | common::LinkCollision::Unchecked | ||
| ); | ||
| is_the_copy.then_some(first.as_path()) |
There was a problem hiding this comment.
LOW · correctness · confidence 0.50 · in collision_winner
Unchecked counts as a match, but it means only that two files have equal size and are above the compare limit. A large placed file from another source with the same size as the first shipper's file will be named as the winner. The doc comment says None means the file came from outside layers, so this overstates what the code proves. Name the layer only on Same, or note the limit. The new test does not cover the Unchecked branch.
What the reviewer checked
common/src/lib.rs:310 Ok(d) if d.len() > COLLISION_COMPARE_MAX => LinkCollision::Unchecked (no content read)
Hand this to an agent
Act on a code-review finding.
File: crates/sandbox/src/lib.rs
Lines: 3048-3053
Category: correctness
Severity: low (reviewer confidence 0.50)
Finding:
`Unchecked` counts as a match, but it means only that two files have equal size and are above the compare limit. A large placed file from another source with the same size as the first shipper's file will be named as the winner. The doc comment says `None` means the file came from outside `layers`, so this overstates what the code proves. Name the layer only on `Same`, or note the limit. The new test does not cover the `Unchecked` branch.
First verify this against the code yourself. It is model output and
may be wrong. If it is wrong, or the tradeoff was deliberate, say so
and change nothing.
👍 useful · 👎 noise — react to tell the reviewer. Replying works too, and says more.
Follow-up to #3272 for gominimal/inbox#1226: the warning for a path two rootfs layers ship with different contents names the layer whose file stays, but only when the layers were hardlinked.
What was wrong.
collision_winnerfinds the winning layer by the inode the assembled path carries. With the package cache and the daemon's state on different filesystems the link pass copies each file, a copy has an inode of its own, and no layer matches. The record then sayswinner = "unknown". A week of lab telemetry (2026-11-09 to 11-16) had that in 42,112 of 42,112 records.The fix. The first-linked file stays, so the winner of a copied file is the first layer, in link order, that ships the path. That layer is named when its file agrees with the placed one by the link pass's own comparison (same bytes, or same size above the compare limit). When it does not agree, the placed file came from somewhere other than the layers and the winner stays
unknown. The hardlink case is unchanged and is tried first, so nothing is read for it.Tests. A new unit test places a copy of the first shipper's file and expects that layer; a later layer with the same bytes does not become the winner; a placed file that is not the first shipper's has no winner. The two existing tests (hardlink, symlink) are unchanged.
Lab evidence. A new scenario runs a task with
node,pnpmandpython, whose layers collide on npm's files and node's man page, on machines where the cache and the state are on different filesystems, and reads each collision record'swinnerfrom the daemon's log.unknownunknownA named winner is checked on the machine: it is a directory, it is not the loser, and it ships the path. Lint (fmt, clippy) and the full pre-push run passed at the tip.
One file,
crates/sandbox/src/lib.rs.🤖 Generated with Claude Code
Summary by CodeRabbit