Skip to content

Commit 36c901c

Browse files
authored
fix: document Hatch cache publish atomicity
1 parent 3257e35 commit 36c901c

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

crates/pet-hatch/src/lib.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,9 @@ impl Locator for Hatch {
208208
// Cold path: parse pyproject.toml + hatch.toml. The
209209
// mtimes we store are the ones we just probed (not
210210
// post-read). If the file changed between probe and
211-
// read, the next configure() will see a different
212-
// mtime than the one stored here and re-parse —
213-
// self-healing under TOCTOU.
211+
// read, the next configure() with an updated mtime will
212+
// see a different value than the one stored here and
213+
// re-parse.
214214
let (virtual_dirs, env_names) = resolve_workspace_hatch_config(workspace);
215215
Arc::new(CachedWorkspaceConfig {
216216
pyproject_mtime,
@@ -232,6 +232,13 @@ impl Locator for Hatch {
232232
// Publish the new caches. Workspaces no longer present are
233233
// implicitly evicted because `next_parsed` was built from the
234234
// current `workspaces` set only.
235+
//
236+
// `workspace_virtual_dirs` is the only cache read by `try_from()` /
237+
// `find()`, so external observers cannot see a half-update. The
238+
// separate `parsed_cache` publish only affects future `configure()`
239+
// calls; a concurrent configure that snapshots the previous parse
240+
// cache will still validate entries against current TOML mtimes
241+
// before reusing them.
235242
*self
236243
.workspace_virtual_dirs
237244
.lock()

0 commit comments

Comments
 (0)