Skip to content

fix(heliopause): fall back when no-replace rename is unsupported - #79

Closed
efegokdemir wants to merge 6 commits into
NVIDIA:mainfrom
efegokdemir:efe/fix-mergerfs-blob-install
Closed

efegokdemir wants to merge 6 commits into
NVIDIA:mainfrom
efegokdemir:efe/fix-mergerfs-blob-install

Conversation

@efegokdemir

Copy link
Copy Markdown

Fixes #54.

On Linux, fall back to hard-link publication when renameat2(RENAME_NOREPLACE) returns EINVAL or ENOTSUP. The link installs the immutable blob atomically without replacing an existing entry, then the temporary name is removed. Existing destinations still return EEXIST; other rename errors are preserved.

Tests cover both unsupported errors, existing destinations and unrelated rename failures. The focused helper harness passed 3 tests; rustfmt --edition 2024 --check heliopause/src/export/archive.rs and git diff --check passed. The Heliopause Cargo test could not compile on macOS because unchanged Helios code uses Linux-only APIs, and mergerfs was not available for a live reproduction.

Use hard-link publication when Linux renameat2 rejects RENAME_NOREPLACE with EINVAL or ENOTSUP. The link preserves atomic no-clobber installation, then the temporary name is removed.

Validation: focused helper harness (3 passed), rustfmt on archive.rs, and git diff --check. The Heliopause Cargo test did not compile on macOS because the unchanged Helios dependency uses Linux-only APIs; mergerfs was unavailable for a live reproduction.

Design-Signed-Off-By: Codex GPT-6; design-review=babb
@original-el8

Copy link
Copy Markdown
Collaborator

The blob-install fallback is correct, but it does not fully fix #54. The default directory export reaches a second no-replace rename after the blob commit:

  • heliopause/src/export/package.rs:982 calls root.export_entry(&committed, path).
  • helios/src/package/cache.rs:2377 calls rename_noreplace.
  • helios/src/package/cache.rs:3559 is still a raw renameat2(..., RENAME_NOREPLACE) with no fallback.

On mergerfs that returns EINVAL as well, so the export moves from "Scan and copy reachable storage" to "Commit package" and still fails. The same pattern exists at cache.rs:3145 (commit_standalone), helios/src/package/export.rs:743, and helios/src/package/conversion.rs:312.

Directories cannot use the hard-link fallback. One option is a directory-specific fallback that checks the destination and then calls fs::rename (documented as non-atomic), or a preflight that rejects a filesystem without RENAME_NOREPLACE before preparation. Either way, "Fixes #54" should become "Partially fixes" unless those paths are covered.

Minor: install_blob_after_rename_error returns remove_file(temporary)? after a successful link, so an unlink failure reports an error even though the destination is installed. The caller (blob.rs:210-218) already removes the temporary and tolerates NotFound, so dropping that ? avoids the false failure.

Probe directory no-replace support beside standalone outputs before capture
or payload assembly. Keep cache-only and packed exports unchanged, preserve
final atomic publication, and drain prepared owners after preflight errors.

Validation: 348 Helios package tests, 8 binding tests, 7 archive tests,
25 package tests, the existing cache conversion regression, and 4 Python
preflight tests using the rebuilt native extension. No GPU or live mergerfs
validation. Full Heliopause tests encounter baseline I/O failures and hangs
on this host; targeted io_uring setup still returns EPERM.

AI assistance: dot (OpenAI; exact model identifier unavailable)

Design-Signed-Off-By: dot (OpenAI, exact model identifier unavailable); design-review=babb
Move the owner-drain regression within its existing module without changing
its assertions or production code. The resulting tree merges cleanly with
current upstream. Eight binding tests pass and the native extension builds.
No GPU execution is needed for this test-placement-only change.

AI assistance: dot (OpenAI; exact model identifier unavailable)

Design-Signed-Off-By: dot (OpenAI, exact model identifier unavailable); design-review=babb
@original-el8 original-el8 added area:caching Prefix/KV reuse, cache retention, and model or payload cache behavior. area:packaging Package assembly, verification, distribution, inspection, and loading. bug Something isn't working priority:P2 Normal bug priority: workflow failure or diagnosis with narrower impact or an available workaround. triage:review Proposed change needs code review; this does not imply merge readiness. labels Nov 5, 2026
A successful hard-link publication must not fail because the fallback also
tries to remove the temporary. BlobStore::commit already owns cleanup and
accepts NotFound. Leave cleanup there, preserving destination validation,
no-clobber publication, link errors, unrelated rename errors, and genuine
non-NotFound cleanup failures.

Add filesystem regressions covering source cleanup ownership and missing
hard-link sources for EINVAL and ENOTSUP. The ownership regression fails on
the original implementation after the destination has been installed.

Validation: all 9 archive tests pass with the locked Heliopause manifest and
--no-default-features. rustfmt and staged diff checks pass. A separate
filesystem harness using the exact helper and caller cleanup block, with
post-link source disappearance injected at linkat, fails with ENOENT before
the fix and passes afterward; caller EACCES propagation remains intact.
This is boundary-level coverage, not a full export-success claim.

The broader no-default-features Heliopause suite hit io_uring EPERM and
stalled dependent transfer cases, then was stopped without a final summary.
Recorded outcomes were 104 passed, 15 failed and 2 ignored. The published
baseline independently fails the exact direct-tail I/O test with the same
EPERM. Default-feature, GPU, Windows and live mergerfs tests were not run.
No environment restriction was bypassed.

AI assistance: dot (OpenAI; exact model identifier unavailable)

Design-Signed-Off-By: dot (OpenAI, exact model identifier unavailable); design-review=babb
@original-el8 original-el8 added the model:gemma4 Affected recipe or documented reproducer: gemma4. Impact may be broader. label Nov 8, 2026
@original-el8

original-el8 commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Updated mergeability check: head 06b9011 merges cleanly into main 5fd4070; the earlier model_core.py conflict is resolved. This is still the candidate fix for #54's unsupported no-replace rename path. Clean mergeability is not a filesystem-correctness approval; publication must still refuse an existing destination and preserve cleanup and concurrency guarantees on the fallback path. No filesystem regression suite was rerun for this update.

Preparing a model on a filesystem without no-replace directory rename must fail before capture rather than publish a partial directory. Main renamed package modules to core modules; merging without adapting the existing publication checks leaves Python imports and Rust call sites referring to removed modules.

Merge main and move the directory-publication preflight calls, Python regression imports and snapshot references to the core names. Retain the immutable-blob hard-link fallback and the directory preflight that preserves existing destinations; no non-atomic directory fallback is added.

Preparation continues to reject unsupported directory publication before capture while using the renamed native interfaces. Immutable blob publication retains its existing no-replace behavior.

On Linux, three Python sequencing tests passed with the native extension case excluded, three Helios directory preflight tests passed, and Heliopause cargo check with locked dependencies and no default features passed. The Python regression failed collection with the removed package import before the repair. The candidate diff against main passes whitespace checks. Native Python extension execution, GPU export, mergerfs reproduction and full repository or hosted CI suites were not run. Unchanged upstream formatting and license whitespace were not rewritten.

Signed-off-by: Efe <gokdemirefe1903@gmail.com>
Design-Signed-Off-By: dot (OpenAI GPT); design-review=ed22

@yatesdr yatesdr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The blob fallback fixes the install failure in #54, but this can't merge as written: it conflicts with main, the directory preflight it adds mostly never runs, and the description no longer matches the branch.

Blocking

  1. Conflicts with main. git merge-tree --write-tree HEAD origin/main reports a content conflict in helios/src/core/conversion.rs against main at c8d8b67. Main turned unpack_selected into a wrapper over unpack_with, so the check at conversion.rs:245 has to move. Please rebase.
  2. The directory preflight does not run from ignition export. The only production call of export_core passes path=None (ignition/cli/serve.py:371), so the checks at ignition/preparation/model_core.py:42 and heliopause/src/export/binding.rs:35 never fire from the CLI. The probes at helios/src/core/cache.rs:2358 and :3125 run after staging has started, so they change the error text but do not fail early. helios/src/core/export.rs:742 and helios/src/core/conversion/edit.rs:250 still publish with a plain no-replace rename and no check. Keep one check where a directory is actually published, and drop the rest, including capture_with_owners (binding.rs:97), which exists only to host the binding check.
  3. The description does not match the branch. It covers only the first commit, says "the temporary name is removed" (30ccc0d moved that to the caller), and says "Fixes #54" although directory publication on mergerfs still fails, now with a clear error. Rewrite it per AGENTS.md, "Required PR descriptions", and use "Partially fixes #54".

Should fix

  1. The fallback treats EINVAL and ENOTSUP as unsupported (heliopause/src/export/archive.rs:479); the probe also treats ENOSYS as unsupported (helios/src/core/cache.rs:3687). Use one set.
  2. tests/preparation/test_directory_preflight.py:28-31 replaces flare_heliopause, torch and torch.distributed in sys.modules, so it checks call order, not behavior. The renameat2 branch of install_blob has no test.
  3. Fold 17a4aa7 and 30ccc0d into the commits they repair, and rebase instead of merging main (06b9011). CONTRIBUTING.md requires Signed-off-by on every commit; 989f013, 2c57bfa, 17a4aa7 and 30ccc0d lack it.
  4. Directory export now requires no-replace rename support. State that next to the same-filesystem rule at docs/multi-host.md:275.

The blob fallback itself is sound: hard-link publication already has precedent (helios/src/core/cache.rs:2583, :3030), and EEXIST keeps the no-clobber guarantee.

@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 79.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review for Agents.

Recommendation: Changes Requested

The blob hard-link fallback is the right, minimal fix for #54 and should be kept; the directory-publication preflight that makes up most of the diff cannot run where #54 happens, leaves the publishers that do run unguarded, mutates the destination while "checking" it, and sits in code main has already rewritten.

Blockers:

  • The preflight cannot run where Export fails with EINVAL when the package cache is on mergerfs (renameat2 RENAME_NOREPLACE unsupported) #54 happens, and the publishers that do run are unguarded. ignition export passes path=None (ignition/cli/serve.py:371, :240 → host_ranks.py:460), so model_core.py:41-42 and binding.rs:33-36 never fire, core.rs:708 is skipped on cache_only, and cache.rs:3125 is test-only — zero probes on that path. Meanwhile publish_staged_directory (helios/src/core/export.rs:735-749, bare rename_noreplace at :742, reached from core.rs:1070) and edit (helios/src/core/conversion/edit.rs:249-252) still fail on mergerfs. Ask: keep one check where a directory is actually published, delete the other four call sites, the export_preflight_directory pyfunction (binding.rs:120-124, registered :128) and capture_with_owners.
  • The probe writes before it validates and reorders an established error. cache.rs:3652 calls create_dir_all(parent) inside a function documented "this probe reserves nothing" (:3621-3622), and conversion.rs:245 runs it before payloads.verify() (:247-248) and before the existing destination exists: {output} check (:289-291). Ask: never create the parent in a check (NotFound instead), and run it after verification so the existing error text survives.
  • The branch does not apply to main. Main made unpack_selected a one-line wrapper over unpack_with (main:300-321); head still carries the inline body with the probe at conversion.rs:245, so that hunk lands in deleted code (the conflict yatesdr reported). Ask: rebase and re-place or drop the check inside unpack_with.
  • The description describes the previous commit series. It still says the fallback removes the temporary (head leaves cleanup to BlobStore::commit, archive.rs:482), claims "Fixes Export fails with EINVAL when the package cache is on mergerfs (renameat2 RENAME_NOREPLACE unsupported) #54", covers 1 of 7 files, omits the whole directory half and the new filesystem requirement, and its evidence ("3 tests") names no command while the diff adds five Rust tests plus a new Python file and never reports whether helios compiled. Ask: "Partially fixes Export fails with EINVAL when the package cache is on mergerfs (renameat2 RENAME_NOREPLACE unsupported) #54", problem first, both halves with before/after, exact commands run and not run.

Should fix:

  • Two errno policies for one syscall. archive.rs:477-480 treats only EINVAL|ENOTSUP as unsupported; cache.rs:3685-3696 also accepts ENOSYS; the repo's own precedent is selene/src/disk.rs:1100-1104. Ask: one predicate beside rename_noreplace (cache.rs:3710), used by both.
  • The probe re-implements existing helpers. ring::SystemRandom plus an unbounded retry loop (cache.rs:3653-3665) next to token() (:2991, already used at :2366/:3133); a manual cleanup match (:3697-3707) where TempDirectory exists (conversion.rs:2454). Ask: .flare-rename-probe-{token()} and one error mapping.
  • Duplicate destination checks with divergent messages. The probe's AlreadyExists (cache.rs:3641-3650) repeats checks every caller already made (:2351-2356, :3118-3123, core.rs:686-700, conversion.rs:289-291), and core.rs checks twice. Ask: one check and one message per component; drop the impossible "rename replaced an existing directory" arm (cache.rs:3674-3679).
  • The new Python test cannot fail on its subject. test_directory_preflight.py:43-52 never enters export_options, so model_core.py:31-33 raises configured core cache first and the unexpected probe is dead; :28-31 fakes flare_heliopause/torch, so only call order is asserted; archive.rs:632-661 repeats :611-629 (its 0o555 premise fails as root) and :686-706/:708-728 are two tests of one 8-line helper. Ask: fix or drop the Python test, keep :611-629 and :662-684, and state the fallback is covered by injected errnos only.
  • The new filesystem requirement is undocumented. No doc changed though directory publication now needs no-replace rename support. Ask: two sentences beside the same-filesystem rule (docs/multi-host.md:275-278), a line where core-format-design.md:703-704 already promises explicit preflight errors, and a docs/TODO.txt entry for the unrun mergerfs reproduction.

Nits:

7 nits (missing SPDX header; capture_with_owners + redundant result bindings; probe doc comment and the one-off #[cfg(any(target_os = "linux", test))]; unexplained synchronize reorder; PyRuntimeError vs FileExistsError convention; title/commit hygiene; non-Linux preflight indistinguishable from success).

To opt out, include #autobot:ignore in your post or comment.

Signed-off-by: Efe <gokdemirefe1903@gmail.com>
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

Keep the blob hard-link fallback — it is the correct, minimal fix for #54 and makes ignition export succeed on mergerfs. Delete the directory-publication preflight that makes up most of the diff: it cannot run on the command #54 reports, leaves ignition edit and publish_staged_directory unguarded, and writes to the destination while documented as reserving nothing.

  • Blockers: 3
  • Should fix: 3
  • Subtractive suggestions: 4
  • Nits: 4

Have your agent review the Full Review for complete findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

@lukealonso lukealonso closed this Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:caching Prefix/KV reuse, cache retention, and model or payload cache behavior. area:packaging Package assembly, verification, distribution, inspection, and loading. bug Something isn't working model:gemma4 Affected recipe or documented reproducer: gemma4. Impact may be broader. priority:P2 Normal bug priority: workflow failure or diagnosis with narrower impact or an available workaround. triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Export fails with EINVAL when the package cache is on mergerfs (renameat2 RENAME_NOREPLACE unsupported)

5 participants