Architecture report · NVIDIA/hyperflare-inference #79

Raw Markdown for agents: https://autobot.eidonix.com/p/93f190a9-a088-4441-b363-c4995fd6683c.md

Architecture and scope review — PR #79, "fix(heliopause): fall back when no-replace rename is unsupported"

Reviewed at head 41f1c76 (7 files, +468/−22, after the 2026-11-27 merge of main; the earlier "branch no longer applies" blocker is resolved — unpack_selected is again a one-line wrapper at helios/src/core/conversion.rs:300-302). Judged against the charter, AGENTS.md, docs/design-review.md and CONTRIBUTING.md (not opened). Lens: architecture and scope only — this review does not re-litigate the concurrency/durability and test-design findings other reviewers raised, except where they bear on scope.

Key findings

Blocking

1. The directory preflight never runs before preparation in any production export path, so the PR does not do what its title and description claim — ignition/preparation/model_core.py:41-42

What the code shows. export_core computes cache_only = path is None (model_core.py:27) and gates the probe on if not cache_only and form == 'directory' (:41-42). ignition export reaches export in two ways, and both pass None:

Consequently, on the reported command:

Why it matters. #54's reported cost is a full preparation pass (~20 minutes) burned before the failure; the change cannot affect that, because the only no-replace publication the export performs is the blob install (archive.rs:275) and the cache entry is published with plain fs::rename (cache.rs:3644), which mergerfs supports. So the PR adds dead code in three layers plus a new public Python function, while the description presents it as the fix — precisely the "present scaffolding as supported" failure AGENTS.md 176-181 forbids, and speculative machinery per AGENTS.md 170-175 ("Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement").

Fix. Delete the probe half — the blob fallback alone is the fix for #54. If a pre-export failure is genuinely wanted, add exactly one call in the CLI where the destination is known, and delete the other four sites and the pyfunction.

2. A per-caller probe fixes a symptom rather than the class, and leaves the two reachable publishers unguarded — helios/src/core/export.rs:742, helios/src/core/conversion/edit.rs:250

rename_noreplace (helios/src/core/cache.rs:4265-4295) is the single primitive every directory publication goes through. This PR adds a separate probe in front of three of its five callers and leaves the primitive untouched, so:

The change therefore introduces a new, undocumented filesystem requirement in one place while the same requirement is neither detected nor explained two other places. The charter's "solve the right problem in the right place, and keep the smallest footprint in shared code" and "Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error" both point at the primitive, not at five call sites.

Fix. Classify the errno once, inside or beside rename_noreplace, and have blob install and every directory caller use that classification — or restrict this PR to the blob fallback and file the directory work separately.

3. One no-replace policy, two different errno sets, in two crates — heliopause/src/export/archive.rs:304-306 vs helios/src/core/cache.rs:4238-4249

The blob fallback treats only EINVAL|ENOTSUP as "unsupported" (archive.rs:304-306). The probe treats EINVAL|ENOTSUP|ENOSYS as unsupported and converts them to a friendly Unsupported error (cache.rs:4238-4249). Same question — "does this filesystem support atomic no-replace publication?" — two answers, in two crates, with no shared predicate. A filesystem that answers ENOSYS gets a working fallback for blobs and a hard failure for directories; a future change to one set silently diverges from the other.

There is in-tree precedent for including ENOSYS (selene/src/disk.rs, unsupported-error classification), so the sets should be reconciled deliberately, in one place, with the chosen set stated in one comment. AGENTS.md 170-175 and 311-317 (policy separation) both cut against duplicating a policy decision across the Helios/Heliopause boundary.

Fix. Hoist the predicate next to rename_noreplace (cache.rs:4265) and have both the blob error path and the directory probe use it.

Should fix

4. The probe mutates the filesystem inside a "check" and reorders established errors — helios/src/core/cache.rs:4205, helios/src/core/conversion.rs:316

preflight_directory_publication_with does fs::create_dir_all(parent) (cache.rs:4205) and then creates a .flare-rename-probe-<32 hex> directory inside it (cache.rs:4206-4218) — directly contradicting its own doc comment "this probe reserves nothing" (cache.rs:4175), the export_entry doc "a failure never exposes a partial export or replaces existing output" (cache.rs:2793-2795) and the commit_standalone doc "a failed or interrupted export never exposes a partial tree and never replaces an existing output" (cache.rs:3667-3669). Three of the call sites already check destination exists themselves without touching the disk (cache.rs:2797-2803, :3671-3677; conversion.rs:364-366), so the probe's own duplicate check at cache.rs:4194-4200 is redundant on those paths.

In unpack_with the ordering is worse: the probe runs at conversion.rs:316, before payload verification (verify_stored_data, conversion.rs:323) and before the established if output.exists() { "destination exists: …" } at conversion.rs:364-366. So an ignition convert to a path under a no-replace-less filesystem now: creates the parent directory and a throwaway probe directory, then reports directory export preflight: … where it previously reported destination exists: … — a behaviour change on the error path, plus leftover directories after a failed conversion.

Fix. Never create the parent in a check — return NotFound and let the publishing path create it. Run the check after validation (and after the existing existence check) so error text and ordering are preserved.

5. The new filesystem requirement is undocumented — no doc file in the diff

docs/multi-host.md states the same-filesystem rule for output vs core cache (docs/multi-host.md:311-317) and says nothing about no-replace rename support; docs/core-format-design.md:713 promises "explicit preflight/export error" for filesystem limits. Issue #54's own "Possible changes" list asks for exactly this note. The change makes directory publication on such filesystems either fall back (blobs) or fail with a specific message (directories) — a supported-configuration statement with no home in the docs. AGENTS.md review standards require checking which configurations are supported and stating new requirements where they belong.

Fix. One or two sentences beside the same-filesystem rule, stating what is required, what falls back, and what is reported.

6. The PR description does not describe this diff — .github PR #79 body

AGENTS.md 67-135 requires, in order: why, exactly what changed, the claimed benefit, and the evidence — and forbids leaving answers to be guessed. At 41f1c76 the description:

Fix. Rewrite as "partially fixes", name the two halves, state the parent-directory side effect, and give the real test counts and what remains untested.

Nit

7. New public API and machinery for a path nothing calls — helios/src/core/cache.rs:4176, heliopause/src/export/binding.rs:97-124

preflight_directory_publication is pub in Helios's cache module solely so the Heliopause preparation-side extension can call it; export_preflight_directory (binding.rs:120-124, registered :126-130) is a new Python entry point called only from model_core.py:42, which production never reaches. capture_with_owners (binding.rs:97-118) is a behaviour-preserving extraction whose only purpose is to make binding.rs:34 observable from a test (binding.rs:1473-1520). The probe also re-implements random-name generation (cache.rs:4207-4211) where token() (cache.rs:3537) already exists for exactly this purpose for sibling staging names (cache.rs:2812, :3686). AGENTS.md 188-193 ("refactoring must directly support the requested behavior"; no speculative machinery) and 330-338 (keep Helios simple) apply. All of this disappears with finding 1; no change is needed if the probe half is dropped.

Verified clean / positives the change deserves credit for

Coverage (all seven changed files read in context, callers followed)

  1. heliopause/src/export/archive.rs — install_blob :259-297, new error path :275, install_blob_after_rename_error :298-313, remove_temporary :314-, tests :436-560. → positive, finding 3, evidence gap.
  2. heliopause/src/export/binding.rs — export_capture :17-95 (probe :34-36), capture_with_owners :97-118, export_preflight_directory :120-124, registration :126-130, test :1473-1520. → findings 1, 7.
  3. heliopause/src/export/core.rs — publish_payload :597-1030 (existence checks :618, :627-632, probe :640-642, staging :643-647, standalone publish :917-947, uncached path :1013-1015). → findings 1, 2.
  4. helios/src/core/cache.rs — export_entry :2796-2824, commit_standalone :3670-3704, preflight_directory_publication/_with :4174-4261, rename_noreplace :4265-4295, cache rename :3644, token() :3537, tests :4515-4585. → findings 2, 3, 4, 7.
  5. helios/src/core/conversion.rs — unpack_selected :300-302, unpack_with :305-451 (probe :316, verify :323, exists check :364-366, publish :436-442). → findings 1, 4.
  6. ignition/preparation/model_core.py — export_core :16-84 (cache_only :27, probe :41-42, sources=True :51-52). → finding 1.
  7. tests/preparation/test_directory_preflight.py (new, 68 lines) — mocks flare_heliopause/torch (:28-31) and asserts call order; it tests the unreachable path. Covered by findings 1 and 7.

Evidence gap (supports findings 1–3; not a separate defect)

No test drives install_blob's real renameat2 branch, and none exercises the probe against a filesystem that actually returns EINVAL: the new Rust tests call install_blob_after_rename_error directly with a synthetic io::Error, and the Python test mocks the extension module. AGENTS.md 176-181 explicitly says mocks that bypass the behaviour cannot establish runtime correctness. What would settle it: a mergerfs (or any EINVAL-returning FUSE mount) run of ignition export — which would also demonstrate, as finding 1 argues from the code, that the blob half alone fixes #54.

Dropped candidates (checked, not reported as findings)

Open question for the maintainer

Should the directory-publication requirement be handled in this PR at all? My recommendation is no: split it — merge archive.rs with its tests and a documentation sentence, and let a follow-up move the errno classification into rename_noreplace, at which point publish_staged_directory and ignition edit are covered for free and no probe is needed.