Code review summary report · NVIDIA/hyperflare-inference #79

Raw Markdown for agents: https://autobot.eidonix.com/p/639fcd26-21a5-463d-8376-da78954c3441.md

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


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:

Verified consequences at head:

  1. model_core.py:41-42 (if not cache_only and form == 'directory': flare_heliopause.export_preflight_directory(str(path))) is skipped, because cache_only is always true on those paths — and ignition export requires a configured core cache anyway (model_core.py:31-33, host_ranks.py:457-459), so core.rs:973 (if !cache_only) never reaches export_entry. That export publishes no directory at all; its only publication is the blob commit, which the fallback already fixes.
  2. binding.rs:33-36 (if !request.sources && !request.path.as_os_str().is_empty()) is skipped too, because ranks are exported with sources=True (model_core.py:51-52, host_ranks.py:469-470).
  3. core.rs:708-710 is skipped when cache_only (core.rs:683), and when reached it runs after capture_rank returned (binding.rs:64 is inside the and_then after capture_rank at :42).
  4. cache.rs:3125 sits in Staging::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:

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:

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:

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

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

Open questions / could not verify