Skip to content

Commit e1d8c54

Browse files
fiskusclaude
andcommitted
Correct five inaccurate claims in the physical_key comments
Review of c3a9243 found five comments whose stated mechanism does not match the code: - `install_paths` doc claimed retaining the remote `s3://` key is what lets a push skip the re-upload. It is not — `matches_content` compares logical_key/hash/size only, so dedup is identical with `file://` keys. Also dropped the "installed rows keep the remote `s3://` key" framing: this function copies rows verbatim, and the installed manifest it is handed carries `file://` for locally committed paths. Recorded the live consequence instead — the caching call parses `physical_key` as an `S3Uri`, so an uncached `file://` row errors rather than being fetched. - `push_package_impl` claimed a later pull or reset clears the stale `file://` keys. Neither can: both short-circuit when `latest` is the hash just pushed. They clear only when another client publishes. - `tag_timestamp`'s collision note read as if the second-pushed revision loses its history entry; it is the first. - `upload_row`'s doc credited the `file://` scheme check with keeping local keys out of published manifests. That comes from the `remote_url` rewrite plus the content-match branch; the check guards the input, and for `s3://` keys `to_file_path` would fail anyway. Comments only; no behavior change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent c3a9243 commit e1d8c54

3 files changed

Lines changed: 31 additions & 32 deletions

File tree

quilt-rs/src/flow/install_paths.rs

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,19 @@ async fn stream_remote_with_installed_rows(
7272

7373
/// Installs paths to already existing manifest (provided as an argument to this function).
7474
///
75-
/// Installed rows keep the remote `s3://` `physical_key`; they are **not**
75+
/// Rows go into the installed manifest **verbatim** — `physical_key` is never
7676
/// rewritten to the `file://` object-store location, despite the `place` value
77-
/// computed in the loop below (logged, never consumed) and the plan sketch's
78-
/// "replace entry's physical key" step (never implemented).
77+
/// computed below (logged, never consumed) and the plan sketch's "replace
78+
/// entry's physical key" step (never implemented). Nothing needs the rewrite:
79+
/// [`matches_content`](crate::manifest::ManifestRow::matches_content) ignores
80+
/// `physical_key`, so a later push dedups by content whatever the scheme.
7981
///
80-
/// That is deliberate: `physical_key` names where the canonical bytes live,
81-
/// and it is what lets a later push skip the re-upload —
82-
/// [`crate::manifest::ManifestRow::matches_content`] ignores `physical_key`,
83-
/// so `push`'s `use_existing_row_or_upload` copies the remote key across.
84-
///
85-
/// So a `file://` key means "these bytes were committed locally" — written by
86-
/// [`commit`](fn@super::commit) and [`create`](fn@super::create) — but it is
87-
/// **not** a local-vs-remote origin marker: a successful push does not rewrite
88-
/// the installed manifest, so `file://` rows outlive their push and clear only
89-
/// when a later pull or reset refreshes the installed copy from the manifest
90-
/// cache. That drift is inert — `top_hash` excludes `physical_key` (see
91-
/// `manifest::top_hasher`), so both copies are the same revision.
82+
/// A row's scheme is therefore just its source manifest's, not an origin
83+
/// marker. `file://` means the bytes were committed locally
84+
/// ([`commit`](fn@super::commit) / [`create`](fn@super::create)) and outlives a
85+
/// push, which never rewrites the installed manifest. Watch out — the caching
86+
/// call below parses `physical_key` as an `S3Uri`, so a `file://` row whose
87+
/// object is missing from the cache errors instead of being fetched.
9288
// TODO: `working_dir` is in `paths` already, and we pass namespace anyway
9389
// so we can remove working_dir from the arguments
9490
#[allow(clippy::too_many_arguments)]
@@ -166,10 +162,9 @@ pub async fn install_paths(
166162
debug!("✔️ Cached object: {}", object_dest.display());
167163
}
168164

169-
// Diagnostic only: `place` is the `file://` URL the row *would* carry
170-
// if installed rows were rewritten to the object store. They are not
171-
// (see above), so this is logged and discarded — the error arm still
172-
// asserts `object_dest` is a valid absolute path.
165+
// Diagnostic only: the `file://` URL the row *would* carry if rows were
166+
// rewritten to the object store (they are not — see above). Logged and
167+
// discarded; the error arm still asserts `object_dest` is absolute.
173168
let place = Url::from_file_path(&object_dest)
174169
.map_err(|()| Error::InstallPath(InstallPathError::Install(object_dest.clone())))?
175170
.to_string();
@@ -178,7 +173,7 @@ pub async fn install_paths(
178173
object_dest.display(),
179174
place
180175
);
181-
// The row goes in unchanged — remote `physical_key` and all.
176+
// The row goes in unchanged — `physical_key` and all.
182177
entries.insert(row.logical_key.clone(), row.clone());
183178

184179
let working_dest = working_dir.join(&row.logical_key);

quilt-rs/src/flow/push.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,9 @@ pub(crate) async fn push_package_impl(
233233
// path never copies it over the installed one (`copy_cached_to_installed`
234234
// below runs only on the hash-mismatch error). So a locally committed row
235235
// keeps its `file://` `physical_key` in `.quilt/installed/` after a
236-
// successful push, until a later pull or reset refreshes it from this cache.
236+
// successful push, and stays that way: pull and reset both short-circuit
237+
// once `latest` is the hash we just pushed, so those keys only go away when
238+
// *another* client publishes a newer revision.
237239
//
238240
// Safe because `top_hash` excludes `physical_key` (see
239241
// `manifest::top_hasher`) — the two copies are the same revision, which is

quilt-rs/src/io/manifest.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ pub async fn tag_timestamp(
105105
// (e.g., try five times with exponential backoff, then Error)
106106
// NB: the key has one-second resolution and holds the *commit* time, so two
107107
// commits of the same namespace made within one second collide even if
108-
// pushed hours apart. `upload_tag` overwrites, so whichever is pushed second
109-
// silently replaces the other's tag — that revision keeps its manifest but
110-
// loses its history entry.
108+
// pushed hours apart. `upload_tag` overwrites, so the second push silently
109+
// takes over the tag and the *first* revision is left with a manifest but no
110+
// history entry.
111111
let tag_timestamp = TagUri::timestamp(manifest_uri, Seconds(timestamp.timestamp()));
112112
upload_tag(remote, manifest_uri, tag_timestamp).await
113113
}
@@ -193,14 +193,16 @@ pub async fn resolve_manifest_uri(
193193
/// though it should be the same as already calclulated during commit.
194194
/// Response with the new `ManifestRow` with `physical_key` pointing to the place it was uploaded to.
195195
///
196-
/// The `file://` scheme check below is load-bearing, not defensive: together
197-
/// with `push::use_existing_row_or_upload`'s other branch (which copies the
198-
/// remote row's `physical_key` across on a content match) it is what keeps a
199-
/// local key out of a published manifest — every row of an uploaded manifest
200-
/// takes one of those two paths. It also closes the reverse leak: a row already
201-
/// keyed `s3://` but not matching the destination's row (a package re-pointed
202-
/// at another bucket, say) hard-errors instead of publishing a manifest that
203-
/// addresses another bucket's objects.
196+
/// A published row's `physical_key` is always remote: either rewritten below to
197+
/// the `remote_url` this upload returns, or copied from the remote row by
198+
/// `push::use_existing_row_or_upload`'s content-match branch. That pair — not
199+
/// the scheme check — is what keeps a local key out of a published manifest.
200+
///
201+
/// The check guards the *input* instead: a row that is not local has no business
202+
/// being uploaded, so a package re-pointed at another bucket hard-errors rather
203+
/// than republishing another bucket's objects. (An `s3://` key would fail
204+
/// `to_file_path` anyway; the check's own catch is host-less schemes like
205+
/// `foo:///abs/path`.)
204206
pub async fn upload_row(
205207
remote: &impl Remote,
206208
host_config: &HostConfig,

0 commit comments

Comments
 (0)