PR #79 — fix(heliopause): fall back when no-replace rename is unsupported
Review of head 06b9011 against main · 7 files · +468/−22 · claims to fix issue #54 · author efegokdemir · branch efe/fix-mergerfs-blob-install
Rules applied: the charter ("smallest footprint in shared code"; "bug fixes need to address the root cause"), AGENTS.md (:47-55 docs/TODO, :67-135 required PR description, :165-169 no weakened guarantees, :170-175 no speculative layers/churn, :176-181 tests must exercise the behaviour), docs/design-review.md (not opened), CONTRIBUTING.md:7-20. No instruction-like content was found in the PR description or comments.
Key findings
- Keep the blob half.
install_blob_after_rename_error(heliopause/src/export/archive.rs:471-486) is the correct root-cause fix for #54, is minimal, and is correct as written. Nothing here asks the author to touch it. - The directory-preflight half does not deliver the stated benefit. On the workflow #54 describes (
ignition export) it never runs at all — that path publishes no directory — and the two directory publishers that do still fail on mergerfs (publish_staged_directory,edit) are left unguarded. That is Blocker 1. - One of the new checks writes to the destination before validating it (
helios/src/core/cache.rs:3652) and moves an established user-visible error — Blocker 2. - The branch conflicts with
mainat theconversion.rshunk (Blocker 3), and the description no longer matches the branch (Blocker 4). - Net: keep
archive.rs; delete the preflight machinery; then either guard the publishers that matter or scope the PR to the blob commit and say so.
Blockers
B1. The directory-preflight half cannot run where #54 happens, and leaves the publishers that matter unguarded
Files: ignition/preparation/model_core.py:41-42 · heliopause/src/export/binding.rs:33-36, :120-124, :128 · heliopause/src/export/core.rs:683, :708-710, :1070 · helios/src/core/cache.rs:2358, :3125 · helios/src/core/conversion.rs:245 · helios/src/core/export.rs:735-749 · helios/src/core/conversion/edit.rs:249-252
Finding. Both production export entry points pass path=None:
- single host —
ignition/cli/serve.py:371:export_core(prepared, recorder, storage, None, ...); - multi host —
ignition/cli/serve.py:240:prepared.export(None, ...)→ignition/preparation/host_ranks.py:460cache_only = path is None.
Verified consequences at head:
model_core.py:41-42(if not cache_only and form == 'directory': flare_heliopause.export_preflight_directory(str(path))) is skipped, becausecache_onlyis always true on those paths — andignition exportrequires a configured core cache anyway (model_core.py:31-33,host_ranks.py:457-459), socore.rs:973(if !cache_only) never reachesexport_entry. That export publishes no directory at all; its only publication is the blob commit, which the fallback already fixes.binding.rs:33-36(if !request.sources && !request.path.as_os_str().is_empty()) is skipped too, because ranks are exported withsources=True(model_core.py:51-52,host_ranks.py:469-470).core.rs:708-710is skipped whencache_only(core.rs:683), and when reached it runs aftercapture_rankreturned (binding.rs:64is inside theand_thenaftercapture_rankat:42).cache.rs:3125sits inStaging::commit_standalone, whose only callers are tests (cache.rs:4441,:4447,:4557).
So on the #54 path zero probes execute. The checks that do run (cache.rs:2358 in Root::export_entry, reached from core.rs:990 via heliopause/src/export/conversion.rs:346, and conversion.rs:245 in unpack_selected) run after the expensive work. Meanwhile the two publishers that still fail on mergerfs are unguarded:
helios/src/core/export.rs:735-749publish_staged_directory— its doc comment claims "identical durability and no-replacement semantics" for both export shapes, and it callscrate::core::cache::rename_noreplace(staging, destination)bare at:742, reached fromcore.rs:1070;helios/src/core/conversion/edit.rs:249-252—rename_noreplace(&staging, request.output)with no probe and no fallback, reached fromheliopause/src/export/conversion.rs:201(export_payload_edit, called fromignition/preparation/core_snapshot.py:91).
Request. Keep exactly one check, placed where a directory is actually published: inside publish_staged_directory (helios/src/core/export.rs:735) and in edit (conversion/edit.rs:249) — or apply the directory fallback original-el8 suggested there. Delete model_core.py:41-42, binding.rs:33-36, the export_preflight_directory pyfunction (binding.rs:120-124) and its registration (binding.rs:128), core.rs:708-710, cache.rs:3125, and capture_with_owners (Blocker 1 makes its only reason go away). Then, because ignition export publishes no directory, "Fixes #54" can become accurate by simply keeping the blob fallback and saying so; convert --output DIR, edit, export_entry and publish_staged_directory are the paths that still need a guard.
Why. AGENTS.md:170-175 rejects "fallback layers … or configuration switches without a concrete requirement" and requires refactoring to "directly support the requested behavior"; AGENTS.md:176-181 forbids presenting partially wired features as supported. Five copies of one check, four of them unreachable or post-hoc, plus a new public Python function whose only caller cannot run, is scaffolding that also leaves the reported defect open.
B2. The preflight mutates the destination before validating and reorders an established error
Files: helios/src/core/cache.rs:3641-3665 (caller helios/src/core/conversion.rs:245-248 vs :289-291)
Finding. preflight_directory_publication_with calls fs::create_dir_all(parent) at :3652 inside a function whose own doc comment says "The final publication must still use rename_noreplace: this probe reserves nothing" (:3621-3622), then creates a .flare-rename-probe-<32 hex> directory (0o700, :3660) with source/target children on the user's destination filesystem. unpack_selected runs it before payloads.verify() (conversion.rs:247-248) and before the existing-destination check (:289-291), so:
- a corrupt or invalid source core now leaves a freshly created output parent behind, where the tree is otherwise cleaned up (
conversion.rs:333-335); - an existing destination now reports
"directory export preflight: destination exists"(conversion.rs:245-246) instead of the established"destination exists: {output}"(:290), while Python callers already pre-check forFileExistsError(ignition/preparation/core_snapshot.py:53-54,:66-67,:78-79,:89-90,:109-110).
Request. Never create the parent inside a check — return NotFound when the parent is missing — and run the probe after payloads.verify() and after (or instead of) the existing output.exists() check, so the existing error and message are preserved.
Why. AGENTS.md:165-169 forbids weakening guarantees, and docs/design-review.md (not opened) principle 12 ("validate the real path and report evidence honestly") is the applicable rule: validation must observe, not mutate. The publish paths document that a failed publication leaves no partial output (docs/core-format-design.md:695-711).
B3. The branch does not apply to main — the unpack_selected hunk is in code that no longer exists
Files: helios/src/core/conversion.rs:240-248 (head) vs main:295-321
Finding. At head, unpack_selected still carries the inline body and the new probe at :245. On main, unpack_selected is a one-line wrapper: unpack_with(source, output, selected, &StartupProgress::silent()) (main:300-302), with unpack_with (main:304-321) verifying through verify_stored_data (main:321). The hunk therefore lands in replaced code — the content conflict yatesdr already reported as their blocking item 1.
Request. Rebase onto current main and re-place or (per B1) drop the check inside unpack_with; confirm with git merge-tree --write-tree HEAD origin/main.
Why. The branch cannot merge as is, and B2's ordering has to be re-derived against unpack_with regardless.
B4. The description describes the previous commit series, not this branch
File: PR description at 06b9011
Finding. AGENTS.md:67-135 requires four answers in order — why, exactly what changed, claimed result, evidence — and :124-127 bans process assurances without technical evidence. At head the description:
- says the fallback "installs the immutable blob atomically without replacing an existing entry, then the temporary name is removed" — head deliberately leaves cleanup to
BlobStore::commit(archive.rs:482,// BlobStore::commit owns temporary cleanup after publication.; testarchive.rs:632), which commit30ccc0demoved there; - claims "Fixes #54" although directory publication on mergerfs still fails wherever it is unguarded (B1);
- describes 1 of 7 files: it never mentions
preflight_directory_publication(cache.rs:3621-3708),export_preflight_directory(binding.rs:120-124),ignition/preparation/model_core.py,helios/src/core/conversion.rs, ortests/preparation/test_directory_preflight.py, nor the new requirement that a destination filesystem support no-replace directory rename (a "compatibility" changeAGENTS.md:87explicitly asks to be named); - offers "a focused helper harness passed 3 tests" with no crate, command or test named, while the diff adds five Rust tests (
archive.rs:612,:632,:663,:686,:708) and a new Python file, and never says whether thehelioscrate — where the largest change lives — compiled.
Request. Rewrite as "Partially fixes #54": problem first (mergerfs returns EINVAL for renameat2(RENAME_NOREPLACE); the failure lands after the ~20-minute preparation pass), then both halves with before/after, then the corrected cleanup sentence, the new filesystem requirement, and the exact commands run and not run (cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server; pytest tests/preparation/test_directory_preflight.py; a live mergerfs run).
Why. Under any reading this is not a formality: a reviewer cannot tell which of the seven files is the fix and which is scaffolding, or which of #54's two options the PR claims to implement. This is also yatesdr's blocking item 3 and original-el8's "Partially fixes" request, still unaddressed.
Should fix
S1. One no-replace policy, two divergent errno sets
Files: heliopause/src/export/archive.rs:477-480 vs helios/src/core/cache.rs:3685-3696; shared primitive cache.rs:3710-3732
The same question — "does this filesystem support no-replace rename?" — is answered with EINVAL | ENOTSUP for the blob and EINVAL | ENOTSUP | ENOSYS for the directory probe, over the same syscall (glibc libc::renameat2 at archive.rs:438-446; libc::syscall(libc::SYS_renameat2, …) at cache.rs:3717-3726). The repository already decided this once at selene/src/disk.rs:1100-1104: Some(libc::EOPNOTSUPP | libc::ENOSYS) => Ok(()). On a kernel or seccomp profile without the syscall, the directory probe reports a clean "filesystem … does not support atomic no-replace directory publication" while the blob in the same export dies on a raw ENOSYS (archive.rs:485).
Request: one predicate beside rename_noreplace (cache.rs:3710), called from both sites, with the chosen errno set and its reason commented once. At minimum add ENOSYS to the archive.rs set.
Why: the charter asks for the smallest footprint in shared code, and AGENTS.md:170-175 rejects a second parallel mechanism for one operation; two policies will drift and already disagree.
S2. The probe re-implements helpers that exist in the same module
File: helios/src/core/cache.rs:3653-3665, :3697-3707
ring::SystemRandom + 16-byte hex + an unbounded AlreadyExists loop, although the same module's token() (cache.rs:2991) is used by both neighbouring publication paths (:2366, :3133); archive.rs:412-431 (create_new inside a bounded 0..100 loop) and conversion.rs:2462-2481 (staging_token/unique_staging) are the established patterns, and conversion.rs:2454-2460 has the RAII TempDirectory guard that would replace the manual (result, cleanup) match. Nothing security-relevant depends on the probe name being unguessable.
Request: .flare-rename-probe-{token()} with a plain create + ?, and one error mapping. (ring is already a runtime-core dependency — helios/Cargo.toml:21, :42 — so this is redundancy plus an untestable error arm, not a new dependency.)
Why: docs/design-review.md (not opened) requires reuse of shared mechanisms rather than parallel copies; AGENTS.md:170-175.
S3. Duplicate destination checks with divergent messages, plus an impossible branch
Files: helios/src/core/cache.rs:3641-3650 vs :2351-2356, :3118-3123; heliopause/src/export/core.rs:686-688 and :695-700; helios/src/core/conversion.rs:289-291
The probe re-checks symlink_metadata(destination) and returns "destination exists", although every caller immediately checked the same thing with a different string ("export destination … already exists", "payload export destination already exists", "destination exists: …"). core.rs even repeats it twice (:686 and :695-700). The new Python test matches one of these vocabularies (tests/preparation/test_directory_preflight.py:65). Also in the probe body, the Ok(()) => "no-replace rename replaced an existing directory" arm (cache.rs:3674-3679) describes a filesystem that ignores RENAME_NOREPLACE, which is not a reachable case — a successful first rename is just the success of the second probe at :3682.
Request: one check and one message per component; drop the impossible arm; reduce the three-arm (result, cleanup) match at :3697-3707 to result.and(cleanup).
Why: AGENTS.md:170-175; three messages for one condition make tests and operator output arbitrary.
S4. The new tests do not establish the behaviour they claim
Files: tests/preparation/test_directory_preflight.py:43-52, :28-31; heliopause/src/export/archive.rs:632-661, :686-706, :708-728
test_cache_only_and_packed_exports_do_not_probe_directory_publicationnever enters anexport_options(...)context, somodel_core.py:31-33raisesRuntimeError("export requires the configured core cache")first andpytest.raises(RuntimeError, match="configured core cache")matches that. Theunexpectedprobe (:45-46) can never run, so the test would pass even if the guard were lost.test_directory_preflight_stops_export_before_capturereplacesflare_heliopause,torchandtorch.distributedinsys.modules(:28-31), so it asserts call order on a path production never takes.- In
archive.rs,:632-661repeats:611-629's "destination and temporary both exist" assertions; its0o555premise ("unlinking needs write permission") does not hold when the suite runs as root, as container builds do; and:686-706/:708-728are two ~20-line tests of one 8-line helper. Keep:611-629and:662-684(theEEXISTcontractblob.rs:204-211relies on), and merge the two error tests into one parameterised case over[PermissionDenied, EINVAL, ENOTSUP]. - No test drives
install_blob's realrenameat2branch (archive.rs:432-470) and nothing exercises an actually unsupported filesystem.
Request: give the second Python test an export_options(tmp_path / "cache") context (or delete it with the hook), drop :632-661, and state plainly in the evidence section that the fallback is covered by injected errnos only.
Why: AGENTS.md:176-181 — "mocks that bypass the behavior cannot establish runtime correctness".
S5. The new filesystem requirement is documented nowhere
Files: docs/multi-host.md:275-278; docs/core-format-design.md:697-704; docs/cli-design.md (not opened) (convert --output); docs/TODO.txt
No changed file is a document, yet the PR adds a requirement that a destination filesystem support atomic no-replace directory rename, enforced at cache.rs:2358 (export_entry, i.e. convert --output DIR with a cache and heliopause/src/export/conversion.rs:346), cache.rs:3125, conversion.rs:245 (unpack_selected, i.e. ignition convert --output DIR), and core.rs:708-710 (publish_payload's directory branch). docs/multi-host.md:275-278 tells operators output and cache must share a filesystem and says nothing about rename support — exactly the trap #54 describes. docs/core-format-design.md:703-704 already promises an explicit preflight error for file-size/space limits; rename semantics is the same class and has no sentence. docs/TODO.txt has no entry for the unrun mergerfs reproduction (search: no match).
Request: one or two sentences beside docs/multi-host.md:275 naming the requirement, the EINVAL/ENOTSUP/ENOSYS symptom and the workaround (destination on a local filesystem), a matching line where the hardlink rule is stated in docs/core-format-design.md, and a docs/TODO.txt entry for the untested mergerfs path.
Why: AGENTS.md:47-55 (documents are present-state specifications; unrun checks go in docs/TODO.txt), and #54 exists in the first place because this constraint was undocumented.
Nits
N1. New test file is the only one under tests/preparation/ without the SPDX header
tests/preparation/test_directory_preflight.py:1 is the docstring; every sibling carries the three-line Apache-2.0 header (e.g. tests/preparation/test_native_publication.py:1-3). Add it above the docstring. (No written rule mandates per-file headers, so this is consistency, not a cited violation.)
N2. capture_with_owners and leftover redundant bindings
heliopause/src/export/binding.rs:97-118 extracts the lease/drain logic only so the unreachable binding probe can be tested; its test (:1047-1093) constructs its own Err and fakes capture/drain, so helper and test prove each other (AGENTS.md:176-181). If the probe goes, inline it back. The same hunk leaves let result = match recorder_lock {…} at :37 and the bare result at :85 redundant — the and_then chain at :46-84 is already the tail expression.
N3. Probe doc comment and the one-off cfg form
cache.rs:3621 says the check runs "before preparing a standalone export", but its callers include export_entry, publish_payload and unpack_selected; say "before publishing a directory core" and keep the accurate "this probe reserves nothing" second sentence. #[cfg(any(target_os = "linux", test))] (archive.rs:471) is the only occurrence of that form in the tree; on non-Linux test builds the helper compiles but its only caller (archive.rs:448, inside #[cfg(target_os = "linux")]) does not — prefer #[cfg(target_os = "linux")] plus #[cfg(all(test, target_os = "linux"))].
N4. Unexplained synchronize reorder
helios/src/core/cache.rs:3117-3126: synchronize(&self.directory) was the first statement on main and now follows the existence check and the probe. Durability is still safe (:3126 precedes copy_tree at :3135 and the publish rename at :3143, and commit_standalone has only test callers), but nothing explains the move; restore it or say why.
N5. The new binding flattens every failure into PyRuntimeError
heliopause/src/export/binding.rs:120-124 maps everything to PyRuntimeError, while the Python side reports "destination exists" as FileExistsError (ignition/preparation/core_snapshot.py:53-54, :66-67, :78-79; tests assert the type). Because the binding cannot, the new test has to match message text (test_directory_preflight.py:65). If the function survives, map AlreadyExists → PyFileExistsError and Unsupported → PyOSError/PyNotImplementedError.
N6. Title and commit hygiene
The title names only the blob fallback although the directory preflight is most of the diff; e.g. "fix(export): fall back for blob publication and preflight directory no-replace support". Reported by yatesdr and not verifiable with these tools (trailers cannot be read): commits 989f013b, 2c57bfa8, 17a4aa76, 30ccc0de reportedly lack Signed-off-by (CONTRIBUTING.md:7-20 requires it on every commit), repair commits should be folded, and main should be rebased onto rather than merged (06b9011a).
N7. The preflight reports success on platforms where it checks nothing
cache.rs:3626-3630 returns Ok(()) on non-Linux, so all three callers read as if a guarantee had been made. The doc comment says so, but worth a comment at the call sites (or an explicit Unsupported result the callers can distinguish). Also: a probe directory is left behind if the process is killed mid-probe (cache.rs:3660), consistent with commit's existing litter risk but worth one line of comment.
Verified and deliberately not reported
- The blob fallback is right and minimal.
archive.rs:481std::fs::hard_linkis atomic, refuses to replace (EEXIST), and temporary/destination always share a directory (blob.rs:177-178), so there is noEXDEVexposure.blob.rs:204-211already treatsEEXISTas reuse of a verified immutable object;blob.rs:216-224removes the temporary and toleratesNotFound, so returningOk(())without unlinking (archive.rs:482-483) is correct.readonlyis applied before install (blob.rs:190-191) and a hard link shares the inode. This matches the existing precedentinstall_payload/install_legacy(cache.rs:2583,:2608). - original-el8's earlier nit is already fixed (the fallback no longer unlinks after a successful link) — do not re-raise it.
- The probe cannot clobber user data — it only renames inside its own freshly created 0700 directory (
cache.rs:3660-3682). - Non-Linux behaviour of
rename_noreplaceis unchanged (cache.rs:3734-3743). - No model-specific branch, flag or environment switch; no new dependency.
- Pre-existing duplication of the
path.exists()check inpublish_payload(core.rs:686and:695-700) is not this PR's doing (though it is worth cleaning while in there).
Open questions / could not verify
- Whether maintainers want the directory requirement addressed in this PR at all. My recommendation is the smaller PR: keep
archive.rs, delete the preflight machinery (~450 of the 468 added lines per the subtractive lens's estimate), and either add one guard inpublish_staged_directory+editor scope the description to the blob commit. - Whether any production path supplies a non-empty
pathwithsources=Falsefor directory form (besidesruntime_core.write(..., sources=False)), which is the only waybinding.rs:33-36could fire. - No tests were run in this review: no Rust or Python suite was executed here. The mergerfs
EINVALclaim rests on #54's reproduction and the PR's injected-errno tests, and no CI result exists for06b9011. Commit trailers could not be inspected with the available tools.