Architecture scratchpad · NVIDIA/hyperflare-inference #79

Raw Markdown for agents: https://autobot.eidonix.com/p/99e09f2a-cd99-42a3-8dec-784c3eb61b19.md

#1 [high] Rules: AGENTS.md scope/rejection criteria and design-review principles

Charter (read_charter): "Solve the right problem in the right place... smallest footprint in shared code"; "Bring real evidence... Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error (#397)"; no unnecessary flags/special cases.

AGENTS.md key lines (at PR head):

docs/design-review.md principles:

AGENTS.md 67-135 Required PR descriptions: four questions in order (why, what changed, claimed benefit, evidence). Description must not leave answers to be guessed. AGENTS.md 38-65 Required prose review (repo-prose skill). CONTRIBUTING.md 7-20: Signed-off-by required on every commit.

#2 [high] Blocking: directory preflight never runs before preparation in any production export path

Head 06b9011. Both production export entry points pass path=None:

Consequences, verified in code:

  1. model_core.py:41-42 if not cache_only and form == 'directory': flare_heliopause.export_preflight_directory(str(path)) is unreachable from ignition export (cache_only is True).
  2. heliopause/src/export/binding.rs:34-36 if !request.sources && !request.path.as_os_str().is_empty() is also unreachable: export_core passes sources=True (model_core.py:51-52) and host_ranks.py:470/686 also pass sources=True. So the per-rank export_capture preflight never fires.
  3. The checks that do run all fire after capture/preparation, so #54's real cost (20 min wasted, issue body) is unchanged:
    • helios/src/core/cache.rs:2358 in export_entry — called only after the cache entry was committed (heliopause/src/export/core.rs:990, after "Commit core"); also from conversion.rs:346.
    • helios/src/core/cache.rs:3125 commit_standalone and helios/src/core/conversion.rs:245 unpack_selected — convert paths, after verification.
    • heliopause/src/export/core.rs:709 in publish_payload — reached from binding.rs:64 after capture_rank returned.

So the feature's stated benefit (fail before preparation, issue #54 option 2) is not delivered on the default ignition export; on mergerfs the export still fails, only with new wording. Combined with AGENTS.md 170-175 (no speculative/partially wired paths) and 176-181 ("Do not present scaffolding or partially wired features as supported"), plus yatesdr's blocking item 2 (one check where a directory is actually published) — this is the core scope finding. Secondary cost: export_preflight_directory (binding.rs:120-124) and the capture_with_owners extraction (binding.rs:97-118, was inline) exist only to host these two unreachable checks; they add a new public Python API surface used by nothing in production.

#3 [high] Should fix: preflight creates the destination parent as a side effect before validation

preflight_directory_publication_with (helios/src/core/cache.rs:3634-3708) ends up calling fs::create_dir_all(parent)? at :3652 and then creates a hidden .flare-rename-probe-<32 hex> directory in that parent (:3659-3665).

#6 [high] Should fix: one no-replace policy, two divergent implementations in two crates

Two no-replace primitives now exist with different policy:

#8 [high] core.rs preflight is post-capture and skipped in the default path

Verified in code (heliopause/src/export/core.rs):

#11 [high] Should fix: description claims Fixes #54 and omits the preflight half

AGENTS.md 67-135 requires four answers in order (why / exactly what changed / claimed result / evidence) and 126-127 explicitly bans "process assurances that add no technical evidence". The PR body at head 06b9011 describes only the first commit's blob fallback ("the temporary name is removed" is stale — 30ccc0de moved cleanup to the caller, archive.rs:482-483), claims "Fixes #54" while directory publication on mergerfs still fails (only the message changes, see entry 2), never mentions the directory preflight, the new Python export_preflight_directory binding, the preflight_directory_publication API, or the broken parent-directory side effect, and reports only "a focused helper harness passed 3 tests" plus rustfmt, with the Helios suite unrun. Under this lens the description matters because the reviewer cannot tell which of the 7 files is the fix and which is scaffolding — exactly yatesdr's blocking item 3. Evidence: PR description text; contrlocal the claim in the PR body that "the temporary name is removed".

#12 [high] Research summary

Reviewed PR 79 (head 06b9011) through the architecture-and-scope lens against the charter, AGENTS.md, docs/design-review.md and CONTRIBUTING.md, reading all seven changed files in context plus their callers. Findings are in the scratchpad (entries 1–11), each with file:line.

Headline: the blob half of the PR is the right fix and is correct as written (hard-link publication with the temporary left to BlobStore::commit, matching the existing install_payload/install_legacy precedent); the directory-preflight half is scaffolding that does not deliver its claimed benefit on any production path. Blocking items: (1) both production export entry points pass path=None and sources=True, so the new model_core.py:41 and binding.rs:34-36 checks are unreachable, and every check that does run (cache.rs:2358, :3125, core.rs:709, conversion.rs:245) fires after capture or preparation — so #54's real cost (a wasted ~20-minute pass) is unchanged and "Fixes #54" is not true; (2) the probe mutates state — fs::create_dir_all(parent) at cache.rs:3652 runs before validation in unpack_selected, leaving new directories from a path that fails. Should-fix: one no-replace policy split into two divergent implementations across two crates (archive.rs:479 vs cache.rs:3687, with ENOSYS differing and rename_noreplace itself unfixed); the new filesystem requirement is undocumented next to docs/multi-host.md:275/docs/core-format-design.md:703 (not opened); and the PR description violates the mandatory four-part scheme and misstates the change. Nit: the capture_with_owners extraction exists only to test the unreachable check. I also recorded what I verified and deliberately did not report — the commit_standalone reordering is durability-safe, the probe cannot clobber user data, non-Linux behaviour is unchanged, and ring is already a runtime-core dependency — plus the evidence gap that no test drives the real renameat2 branch or mergerfs.

#13 [high] FINAL: consolidated verified findings for the report (architecture & scope lens)

PR 79, head 06b9011. Lens: architecture and scope. Rules cited: charter ("solve the right problem in the right place"; bug fixes must address the root cause, not swallow/retry — #397; "bring real evidence"); AGENTS.md 67-135 (four-part PR description), 137-151 (scope/rejection), 165-169 (no weakened guarantees), 170-175 (reject unsupported abstractions, fallback layers, churn; "refactoring must directly support the requested behavior"), 176-181 (focused meaningful validation; "Do not present scaffolding or partially wired features as supported"; mocks cannot establish runtime correctness), 191-194 (identify violation, recommend rejection, do not rescue by adding an opt-in); docs/design-review.md principles 12 and 15; CONTRIBUTING.md 7-20 (Signed-off-by).

=== Summary judgement === The blob change (heliopause/src/export/archive.rs) is the correct, minimal root-cause fix for #54 and matches existing precedent (helios/src/core/cache.rs:2583-2603 install_payload, :2608 install_legacy: hard_link, EEXIST = no-clobber, caller removes the staged link). Keep it. The bundled directory-preflight machinery is scaffolding that never runs where it was meant to, changes a published contract without documenting it, and should be dropped back to a single check where the directory is actually published (this is also the maintainer's blocking item 2 in yatesdr's 2026-11-18 review).

=== BLOCKING 1 — the directory preflight never runs before preparation, so the PR does not fix #54 === Files/lines: ignition/preparation/model_core.py:41-42; heliopause/src/export/binding.rs:34-36; heliopause/src/export/core.rs:708-710; helios/src/core/cache.rs:2358, :3125, :3621-3708; helios/src/core/conversion.rs:245. Wrong: Both production export entry points pass path=None — single host ignition/cli/serve.py:371 (export_core(prepared, recorder, storage, None, ...), form defaults to 'directory'), multi host ignition/cli/serve.py:240 (prepared.export(None, ...) -> host_ranks.py:460 cache_only = path is None). So (a) model_core.py:41 refuses to run; (b) binding.rs:34 also refuses, because export_core passes sources=True (model_core.py:51-52; host_ranks.py:470 and :686 likewise) and request.path is empty; (c) core.rs:708 is skipped because path is empty (cache_only, core.rs:683) and on the standalone-destination path it runs inside publish_payload, i.e. after capture_rank returned (binding.rs:42-45); (d) cache.rs:3125/2371 and conversion.rs:245 are convert/commit paths that run after the tree is assembled. Why it matters: on mergerfs the export still fails — after tuning, compilation, capture and blob scanning — so #54's actual cost (the issue body: a full ~20-minute preparation pass per attempt) is untouched; only the error text changes. AGENTS.md 176-181 forbids presenting a partially wired feature as supported, and 170-175 forbids speculative machinery; the PR is titled and described as the fix while adding dead code in three layers plus a new public Python function (export_preflight_directory, binding.rs:120-124) that nothing in production calls. Fix: keep one check, placed where a directory is actually published (export_entry, commit_standalone, unpack_selected, publish_staged_directory) — or, if the goal is to fail before preparation, wire exactly one call into the real entry points (the CLI, where the destination is known) and delete the rest; state "Partially fixes #54" otherwise.

=== BLOCKING 2 — the probe mutates the filesystem before validation === File/line: helios/src/core/cache.rs:3652 (fs::create_dir_all(parent)), :3653-3665 (creates .flare-rename-probe-<32 hex>), doc comment :3621-3622 ("this probe reserves nothing"); caller helios/src/core/conversion.rs:245 runs it before payloads.verify() at :248 and before staging at :292. Wrong: A function documented and used as a precondition check creates the destination's parent directory (and a throwaway directory inside it) as a side effect. A conversion that then fails verification, or any export that fails after the check, leaves newly created directories behind; previously the "destination exists"/verification errors were produced without touching the filesystem. Why it matters: AGENTS.md 165-169 (do not weaken guarantees) and principle 12 (validate the real path); silently introducing parent directories from a failed check contradicts the publish paths' documented "a failure never exposes a partial export" property. Fix: refuse a missing parent (return NotFound) instead of creating it, or run the probe immediately before the rename it is validating, after the parent is known to exist and validation has passed.

=== SHOULD FIX 3 — one no-replace policy, two divergent implementations in two crates === Files/lines: heliopause/src/export/archive.rs:472-486 (EINVAL|ENOTSUP) vs helios/src/core/cache.rs:3685-3696 (EINVAL|ENOTSUP|ENOSYS); primitive helios/src/core/cache.rs:3712-3732 rename_noreplace, used unchanged by cache.rs:2371, :3143, conversion.rs:324, export.rs:742, conversion/edit.rs:250. Wrong: The same question — "does this filesystem support no-replace publication?" — is answered differently in two crates, and ENOSYS is treated as unsupported on one path and not the other. Neither the blob fallback nor the classification lives in the shared primitive. Why it matters: AGENTS.md 170-175 and the charter's "smallest footprint in shared code"; two policies for one operation will drift, and a filesystem answering ENOSYS gets a fallback for directories but a hard error for blobs. Fix: put the errno classification in one place (beside rename_noreplace) and have both callers use it; state the chosen set in one comment.

=== SHOULD FIX 4 — the new filesystem requirement is undocumented === Files/lines: docs/multi-host.md:275-278 (the existing same-filesystem rule); docs/core-format-design.md:703 (promised explicit preflight/export error for filesystem limits); issue #54 "Possible changes" item 2 asks for exactly this. Wrong: The change makes a standalone directory export require no-replace rename support, and no document says so; PR touches no docs. Why it matters: AGENTS.md review standards require checking which configurations are supported and stating new requirements; #54 exists because the constraint was undocumented. Fix: one sentence next to the same-filesystem rule.

=== SHOULD FIX 5 — PR description === Wrong/why/fix: Per AGENTS.md 67-135 the description must give why / exactly what changed / claimed result / evidence in order and must not contain process assurances. At 06b9011 it covers only the blob commit, says the temporary name is removed (30ccc0de moved cleanup to the caller — archive.rs:482-483), claims "Fixes #54" while directory publication on mergerfs still fails, never mentions the directory preflight, export_preflight_directory, or the parent-directory side effect, and offers only "a focused helper harness passed 3 tests" with the Helios suite unrun. Rewrite as "partially fixes", name the two halves, and state which checks ran and what remains untested.

=== Evidence gap (supports 1/5, not a separate defect) === The five new Rust tests (archive.rs:612-720) call install_blob_after_rename_error directly with a synthetic io::Error; nothing drives install_blob's real renameat2 branch, and no test uses an unsupported filesystem (yatesdr should-fix 5). tests/preparation/test_directory_preflight.py:28-31 replaces flare_heliopause, torch and torch.distributed in sys.modules, so it asserts call order, not behaviour — AGENTS.md 176-181 says mocks that bypass the behaviour cannot establish runtime correctness. A mergerfs (or any EINVAL-returning FUSE mount) run of ignition export would settle whether the PR actually fixes #54.

=== NIT 6 — capture_with_owners is scope churn === heliopause/src/export/binding.rs:97-118 extracts the lease/drain logic out of export_capture (behaviour preserved; test at :1044-1090). It exists only so a unit test can observe that the unreachable binding preflight returns before capture; if blocking 1 is fixed by dropping the binding check, revert to the inline form (AGENTS.md 170-175).

=== Verified and deliberately NOT reported === commit_standalone reorder (cache.rs:3117-3126) is durability-safe: synchronize(&self.directory) still precedes copy_tree (:3135) and the publish rename (:3143), staging is synced at :3139, and commit_standalone has only test callers (:4441, :4447, :4557). The probe cannot clobber user data — it only touches paths under the 0700 random directory it just created (:3653-3665, EEXIST-retry). Non-Linux behaviour is unchanged (cache.rs:3626-3630 returns Ok; binding.rs:122 becomes a no-op, consistent with the non-Linux rename_noreplace at :3735-3743). ring is already a runtime-core dependency (helios/Cargo.toml:21,42; heliopause/Cargo.toml:23), so SystemRandom adds no dependency and no "pin everything" violation. No env-var switch, no per-model branch, no new flag — the model-agnostic and explicit-configuration rules are not engaged. Pre-existing duplication of the path.exists() check in publish_payload (core.rs:686 and :695-700) is not this PR's doing. Commit signing/trailer requirements (CONTRIBUTING.md 7-20; yatesdr should-fix 6) were not re-verified against the individual commits and are outside this lens.

#4 [medium] Should fix: new filesystem requirement is undocumented

docs/multi-host.md:275-278 states the filesystem requirement for export ("Output and core cache must be on the same filesystem for hardlinks"), and docs/core-format-design.md:703 promises an explicit preflight/export error for filesystem file-size and space limits. PR 79 adds a new requirement ("no-replace directory publication must be supported") and changes the supported matrix: a standalone directory export now fails where it previously worked on filesystems that accept RENAME_NOREPLACE but reject ... actually previously it also failed at rename; but the probe widens the failure to EISDIR-adjacent cases and adds Unsupported for ENOSYS.

No doc change is in the PR (only the 7 files listed). Per AGENTS.md 405-418/principle 13 and the review standard "Check interactions across every supported ... configuration ... verify that existing data, artifacts, and exported cores still load", and yatesdr's should-fix 7, the new requirement should be stated next to docs/multi-host.md:275. Also docs/core-format-design.md:703 is the place the issue (#54 "Possible changes" 2) points to for a documented preflight.

#7 [medium] Positive: blob hard-link fallback is sound; tests don't reach it

The blob half of the PR is architecturally right and should be kept:

Test-coverage gap (AGENTS.md 176-181 "Tests must exercise the affected behavior"): the 5 new Rust tests call install_blob_after_rename_error directly with a synthetic io::Error; none drives install_blob's real renameat2 branch (yatesdr should-fix 5), and nothing exercises mergerfs. tests/preparation/test_directory_preflight.py:28-31 replaces flare_heliopause/torch/torch.distributed in sys.modules, so it asserts call order rather than behaviour.

#9 [medium] Nit: capture_with_owners extraction is scope churn tied to the dropped check

heliopause/src/export/binding.rs:97-118 extracts capture_with_owners out of export_capture (previously inline at the old lines 29-105). Behaviour is preserved (OwnerLease retained unless drain succeeds) and binding.rs:1044-1090 adds a unit test of the extraction.

Assessment: this is not a git diff-only nit. AGENTS.md 170-175 rejects unsupported abstraction and "refactoring must directly support the requested behavior"; here the refactor exists only so a unit test can observe that the newly added preflight (binding.rs:34-36, unreachable — see entry 2) returns before capture. If the reviewer's item 2 is accepted and the binding preflight is dropped, capture_with_owners loses its only reason to exist and should revert to the inline form. Not itself a defect; scope churn to flag at nit severity.

#10 [medium] Cleared: candidates I verified and dropped

Attempted cross-checks that came up clean, so they should not be reported as findings:

#5 [low] Doc finding cross-reference

Verified in code: