Recommendation: Ready To Merge
Rebased onto main (cc0a49d2, which includes merged #670), PR #678 cleanly addresses every Round 1 review item: _EXTRA_ROOTS is now encapsulated behind current_source_roots(), #670's narrow with bind_source_roots(extra_roots): scope in rank_group._peer is untouched, the PR description accurately frames both the on-main failure mode and the defensive nature of tuning_replicas propagation, and the CPU spawn tests assert real ForwardCache.root agreement against an unbound baseline. No correctness, safety, concurrency, or regression issues remain at 90b0d31; merge once the Python CPU tests workflow completes green and triage clears the stale duplicate label.
Merge Risk
Level: Low
- Minimal, preparation-only footprint: Only +136/−20 lines across 5 files (production code is +18/−8), with no runtime/Helios/ABI/core-format changes and zero hot-path overhead; plain in-tree
ignitionruns continue to bind(). - Clean spawn-boundary dataflow: Both
rank_group.prepare_groupandtuning_replicas.prepare_recipecapturecurrent_source_roots()(an immutable, picklabletuple[tuple[str, Path], ...]) in the parent and rebind via the existingContextVartoken-reset context manager in the spawned child, introducing no new locks, threads, or failure-propagation changes. - Disjoint from concurrent PR #695: Although open PR #695 also edits
ignition/preparation/tuning_replicas.py, it modifiesauthorization()andReplicaPreparation(lines32-125), leaving #678's edits in_replicaandprepare_recipe(lines142-194) non-overlapping.
Walkthrough
ignition/preparation/source_identity.py:17-24: Adds publiccurrent_source_roots() -> tuple[tuple[str, Path], ...]returning_EXTRA_ROOTS.get()(mirroringignition/registry.py'scurrent_recipes()/current_prog()pattern) and updatessource_roots's docstring for active CLI and spawned worker contexts.ignition/preparation/aot.py:845-847andignition/preparation/rank_group.py:295-297: Replaces direct private_EXTRA_ROOTSimports withcurrent_source_roots(), leaving_EXTRA_ROOTSreferenced solely insideignition/preparation/source_identity.pyand preserving #670's narrowwith bind_source_roots(extra_roots):block inrank_group._peer.ignition/preparation/tuning_replicas.py:142,153,158,174-176,190-194: Capturesextra_source_roots = current_source_roots()inprepare_recipe, passes it as a required positional argument to_replica, and bindswith source_roots(extra_source_roots), CoreStorage(world=plan.world_size) as storage:around replicaprepare(...).tests/preparation/test_forward_cache_sources.py:35-48,151-245: Extracts_stub_forward_cache_root()usingpytest.MonkeyPatch.context(), migrates_record_source_roots_preparetocurrent_source_roots(), addstest_current_source_roots_reflects_active_scopecovering nesting/reset, and adds Linux/Heliopause-gatedtest_prepare_recipe_propagates_source_roots_to_spawned_tuning_replicaverifying real-spawnpropagation andForwardCache.rootagreement against the unbound baseline.
Pre-merge Checks
- [PASS] Security / malicious screen: No unsafe deserialization, command execution, credential exposure, or prompt-injection content; only picklable
(str, Path)tuples crossmp.get_context("spawn"). - [PASS] Charter & value fit: Right layer, clean encapsulation matching
ignition/registry.py, no flags or model/recipe coupling, and complete four-part PR description with honest disclosure of defensive scope and CPU-test limitations (AGENTS.md:72-154,docs/design-review.mdPrinciples 16–17). - [PASS] Related / duplicate / conflict check: Properly rebased onto merged #670 (
cc0a49d2); edits intuning_replicas.py:142-194do not overlap PR #695'sauthorization()/ReplicaPreparationchanges. The existingduplicatetriage label is now stale and can be removed. - [WARN] Tests & verification evidence: Author reports 36/36 CPU tests passing across 7 suites (with CUDA/CoreStorage stubbed inside the spawned replica test), but no GitHub Actions CI run is recorded on head
90b0d31yet—confirm.github/workflows/python-cpu.yml(not opened) passes before merging.
Blockers
None.
Should Fix
None.
Subtract / Simplify
- Optional scope trim (
ignition/preparation/tuning_replicas.py:142,153,158,174-176,194andtests/preparation/test_forward_cache_sources.py:163-245): Because_replicainvokesprepare(..., compile_forwards=False)and exits onTuningComplete(ignition/preparation/tuning.py:618-624,tuning_replicas.py:159-165), no in-tree caller readscurrent_source_roots(),ForwardCache, orsource_identity()on the tuning-replica path today (as the PR description transparently notes). The production addition is only +8/−3 lines and harmless as defensive parity for external recipes, so keeping it is fine; however, if maintainers prefer strictly zero speculative plumbing perAGENTS.md:165-169,188-193, dropping thetuning_replicas.pypropagation and its 84-line spawn test trims the PR to the ~10-linecurrent_source_roots()encapsulation refactor.
Nits
- Parameter naming consistency (
ignition/preparation/tuning_replicas.py:142,158,176,194): Usesextra_source_roots, whereasignition/preparation/rank_group.py:45,60,297,310andignition/preparation/source_identity.py:33,48name the same tupleextra_roots. - Reuse test helper (
tests/preparation/test_forward_cache_sources.py:104-109):test_prepare_group_propagates_source_roots_to_spawned_peerscan call the newly extracted_stub_forward_cache_root()forbaseline_rootinstead of manually patchingaot.torch.cuda.get_device_properties.
Dropped on verification
- "
_replicacalls_resolve_recipebefore bindingsource_roots(tuning_replicas.py:155vs:158), so a recipe importable only via a bound external root would fail" — False.source_roots()(ignition/preparation/source_identity.py:22-30) only sets the_EXTRA_ROOTSContextVar; it does not touchsys.path,importlib, orignition.registry._ACTIVE_RECIPES. Moreover,prepareis unpickled (importingprepare.__module__) bymultiprocessingbefore_replicais even entered. - "Multi-host
ignition join(ignition/cli/serve.py:546) still computessource_identity()with no bound roots" — False.ignition/cli/__init__.py:364-372wrapsargs.handler(args)—includingjoin—inwith bind_source_roots(source_roots):, andhost_ranks.serve_peer()(ignition/preparation/host_ranks.py:597-657) runs in-process without spawning, so external-recipe CLIs passingsource_rootsalready bind them on joining hosts. - "
rebuild_manifest.py:329executes in a spawned child and changes recorded artifact metadata" — False. Every caller ofrebuild_manifest.from_plan(ignition/cli/serve.py:235-237and:336-338) runs in the rank-0 CLI parent process, wheresource_rootswas already bound prior to this PR. - "Merge conflict with open PR #695 on
tuning_replicas.py:190-194(_replicaargs tuple)" — False. PR #695 modifiesauthorization()andReplicaPreparation(tuning_replicas.py:32-125), which is disjoint from PR #678's changes in_replica/prepare_recipe(:142-194). - "The tuning-replica test bypasses production
_replicaby monkeypatching it" — False / overstated._cpu_replica_entry(tests/preparation/test_forward_cache_sources.py:199-207) is a child-side bootstrap wrapper needed becausemp.get_context("spawn")starts a fresh interpreter; it stubs CUDA/CoreStorageinside the child and then invokes the realtuning_replicas._replica(*args), genuinely exercising parent capture, spawn pickling, child rebinding, andForwardCache.roothashing. - "Linux-only skip marker leaves Windows spawn untested, and
ranks is not None/ emptytuning_gpusare untested" — Low-signal / out-of-scope.tuning_replicas._replicaexplicitly callsflare_heliopause.bind_parent_lifetime(parent)(tuning_replicas.py:149), CI runs onubuntu-24.04(.github/workflows/python-cpu.yml:14(not opened)), and requesting tests for untouched branches on Round 2 violates scope discipline. - "Pre-existing
source_identity(*, extra_roots=())keyword is dead fallback plumbing (source_identity.py:33,48)" — Out-of-scope. Untouched public API parameter outside this PR's diff. - "Drop
test_current_source_roots_reflects_active_scope(tests/preparation/test_forward_cache_sources.py:151-160)" — Low-signal. It is a crisp 10-line unit test directly covering the new public accessor's default, nesting, and reset behavior.