feat(mods): an Atmosphere patch set imports as a mod of ExeFS patches, and an unimported one says so #3169
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3169
Loading…
Reference in a new issue
No description provided.
Delete branch "snaildev99/Longshot:mods/atmosphere-patch-sets"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Many ExeFS mods ship as an Atmosphere patch set: a folder of
.ips/.pchtxtfiles underatmosphere/exefs_patches/<name>/, which Atmosphere and the emulators read as they are.mainbuilds a plain mod'sexefs/patches in place (#3137), and its walk already recognised a patch set, but nothing used that: a set has noexefs/, so it was never built in,mod importskipped it, and its Mods tab row said nothing about why.With this change:
mod importfinds every patch set in a folder or archive (several in one pack, beside acontents/<title id>/mod, and inside another emulator mod's folder, such as a pack with
romfs/at its root, included) and converts eachinto a mod whose
exefs/holds its patch files, with theexefspermission. A readme is left out, as the import'sother left-out files are.
naming both: the player imports each folder alone, with
--namefor one. An import over the profile's mod of thesame id (an earlier import) takes its place as on
main, and its result now says so (replaced).has its patch files (it was imported), the row says so instead, directs the player to that mod's row for acceptance
and build status, and says the folder can be removed.
This ports the patch-set commits of #1036's branch, which had no pull request of their own. It is rebased on #3137,
which removed the start's
mod_needs_importwarning; this pull request's addition to that warning went with it.Read first:
game/crates/modtool/src/import.rs(is_emulator_mod,find,convert),game/crates/modtool/src/service.rs(import_found), thengame/crates/code-mods/src/lib.rs(patch_set_files) andgame/crates/api/src/loader/mod.rs(code_statusand the row's note intexts).Testing
Tested: Windows 11 Pro, RTX 3090, NVIDIA 610.88, in the game, built by
longshot-builder play --profilewiththis PR and the other mod compatibility ports merged, adult Link in Kakariko.
After the rebase onto
main@3a0f7d8f7, here @f709e175c, built with the other ports merged (929bf025a), thesame profile, which holds the imported
local/rupee-counter-off: the patch set's row says "Imported: another mod hasthese patch files (its converted copy), and they are built in from that one. This folder can be removed."
(screenshot in the comments), and the rupee counter is gone while that mod is on. The import itself was not run
again in the game after the review's fixes; their tests are in Measurements.
Before the rebase (@
571321351, onmain@f577a1aea): a patch set(
atmosphere/exefs_patches/Rupee Counter off/, one.ipsthat writes back Rupee Counter's hook) left in theprofile's
mods/: the start warned that it was in an emulator's layout and not imported (that warning leftmainwith #3137).
Longshot.exe mod importof that folder madelocal/rupee-counter-offwith the patch inexefs/and theexefspermission; after accepting its code it was built in, and in the game the rupee counter was gone (the overlap PR has
the log line). With the patch set's folder still in
mods/atmosphere/exefs_patches/, its row's page says "Import thisfolder once with
Longshot.exe mod import <folder>: its code patches are not built in until then."; onmainthesame row says nothing of it (screenshots in the comments). Game-free: the seven tests in Measurements, and
a_patch_set_is_only_a_folder_of_patch_files_in_exefs_patches(code-mods).mise run test, run locally while CI's run waits for approval (Windows 11,tests/run_all.py --strict, 12 checks atonce), here @
f709e175cand onmain@3a0f7d8f7: 847 passed, 12 failed, 52 skipped here; 845 passed, 14 failed,52 skipped on
main. All 12 also fail onmain: test_dlssg, test_fsr4_tune, test_lifter, test_no_game_title,test_no_map_reload, test_present_acquire_ahead, test_present_geometry_trace, test_present_held_image,
test_present_image_free, test_sync_watch_event, test_turf_budget, test_ui_renderer.
Still to test:
None
Measurements
Verdict: It works: a patch set imports as a mod whose patches are built in, and an unimported one says so.
Nothing changes per frame or in the build of a profile without patch sets; the import runs once, when the player asks.
Setup:
cargo testofcode-mods,game-files,modtoolandapion Windows 11,main's code with the new testson the before side; then the test profile in the game. The before side of the first two rows was run on
main@f577a1aea, before the rebase.f577a1aeaf709e175ca_patch_set_is_converted_into_exefs,several_sets_in_one_pack_and_a_contents_mod_beside_them,a_converted_set_is_found_by_patches_collect(modtool)an_unconverted_patch_set_says_to_import(api)The review's fixes, each test run on this pull request's own code before its fix (rebased on
main@3a0f7d8f7,4d56570af) and after:
f709e175ca_pack_with_a_root_romfs_and_a_patch_set_imports_both(modtool)local/packimported, the set inside it left outtwo_sets_of_one_name_are_refused_before_anything_is_written(modtool)local/fps, the first lostan_imported_patch_set_says_so_and_not_to_import_it(api)Risks
mod emulatorsand the mod fingerprint still look atexefs/only, so a pack that only hasatmosphere/exefs_patchesisn't offered there;mod importof the folder or archive finds it.romfs/is walked as a RomFS mod (its row doesn't say to import), andthe import copies both.
mod importnow looks inside an emulator mod's folder for patch sets (not in itsromfs/,exefs/orcheats/),up to four folders deep, so a pack that ships the same patches in
exefs/and inatmosphere/exefs_patches/<name>/imports both copies, as two mods writing the same bytes.
mainwrote both and kept the last. Apack whose root mod and a patch set inside it have one name is refused too: the set's folder imports alone (with
--name), and the root'sromfs/plays without import.mods/says on its Mods tab page to import it, then that it was imported. No save,setting or cache changes. A revert is enough.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (run locally, Testing names them; CI's run waits for approval)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
tests/that reads changed source is updated, not weakened. (tests/test_recomplauncher_json.pyreadscode_mods.rs,tests/test_doc_commands.pythe modtool's commands,tests/test_sandbox_profile.pythe loader: all pass unchanged;tests/test_parity_gates.py's one failure on this PC, a G: tree with C: temp, fails onmaintoo)mainand here, for a change that shows on screen. (in the comments)Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Tested in game: Windows 11 Pro, RTX 3090, NVIDIA 610.88, adult Link in Kakariko, built by longshot-builder play --profile with the mod compatibility ports merged: an Atmosphere patch set left in mods/ was named at the start as not imported; mod import made it a mod with its .ips in exefs/ and the exefs permission, and once its code was accepted it was built in and took effect in the game.
Possibly related, for context:
Screenshots: the page of an Atmosphere patch set left in the profile's
mods/atmosphere/exefs_patches/without an import, the same test profile on both sides (Windows 11, RTX 3090).Before, main @

f577a1aea: the row says what it has, and nothing of why its patches are not built in.After, this PR (the build with the other mod compatibility ports merged, 72d64e92f): its notes say to import it once.

Description updated: the unimported patch set's Mods tab page, here and on main, is in the comment above, and the checks under tests/ that read the changed files are named (all pass; the one failure on this PC also fails on main).
mise run test, run locally while CI's run waits for approval (Windows 11, run_all --strict, 12 checks at once), here @
571321351and on main @f577a1aea: 833 passed, 12 failed, 51 skipped here; 820 passed, 25 failed, 51 skipped on main. 11 of the 12 also fail on main (named in Testing). The other, test_prepare_stall (a timed watchdog check), failed in the run and once alone under load, then passed alone, as it does alone on main. Box ticked.WIP: feat(mods): an Atmosphere patch set imports as a mod of ExeFS patches, and an unimported one says soto feat(mods): an Atmosphere patch set imports as a mod of ExeFS patches, and an unimported one says soRecommendation: Request changes. Import can silently skip patch sets in mixed packs and overwrite another imported mod when names collide. The warning also persists after a successful import, so it cannot tell the player when the action is complete.
The change converts Atmosphere patch sets into manifest mods and explains why unimported sets are not built in. It adds useful coverage, but discovery and destination handling need to protect all of a pack’s patches and existing mods.
Blocking (3): must change before merging.
game/crates/modtool/src/import.rs:60: Discovery stops at an emulator mod and never searches it for patch sets elsewhere in the same pack. (more on the line) Do: Discover nested patch sets independently of an enclosing emulator-layout mod, and add a command-level test for a pack with root romfs and a patch set.game/crates/modtool/src/import.rs:134: Patch sets are assigned destination IDs solely from their final folder name, without detecting collisions before import writes them. (more on the line) Do: Preflight destination IDs and existing mods before writing; refuse collisions or give each set a distinct ID with an explicit replacement policy.@​fixor@​rebasetry first). (for the author)Should fix (1): not blocking, but worth doing before merging.
builder/crates/game-files/src/mod_layout.rs:29: The new warning treats the original patch set as unimported even after import succeeds. (more on the line) Do: Make the workflow remove or identify the original after a successful import, or tell the player explicitly to remove the original folder after verifying the imported mod.@fixcan do L1, L2 and L3.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for the tested case: the author reports that one patch set imported and took effect in game on Windows, and the new tests failed on main and passed on this head. Multiple-set and mixed-pack command behavior still has the defects below.
Other systems: The builder’s startup warning, the game’s Mods tab, archive imports, profile state and existing manual mods are affected. The reported game run was on Windows; CI is still running. No rendering, audio, input or save code changed.
Switches: None.
Reviewed:
5713213519againstf577a1aeab: Read the repository rules, standards, PR template, diff, commit and changed import and layout code; traced the service’s import and write paths and the loader’s row construction. Skimmed the remaining large changed files, documentation and tests; the combined output for those reads was truncated. Tooling’s adjacent AGENTS.md and docs/review-checklist.md were absent.; nothing run (a code review).Checked and fine:
Testing: No commands from the project or tests were run for this review. The author reports a Windows in-game run and game-free tests; the supplied CI checks are still running.
Overlaps and merge order: #3137 touches the same mod compatibility paths; the PR says whichever lands second must incorporate the other. Merge order is not established.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as snaildev99 took it out of WIP. Nothing was run; a maintainer decides.
@ -25,3 +27,3 @@pub fn needing_import(mods: &Path) -> Vec<String> {fn is_mod(d: &Path) -> bool {LAYOUT.iter().any(|p| d.join(p).is_dir())LAYOUT.iter().any(|p| d.join(p).is_dir()) || code_mods::is_patch_set(&code_mods::Fs, d)L3 (should fix): The new warning treats the original patch set as unimported even after import succeeds.
When: Import copies the patches to a new manifest mod and leaves the original folder in mods/. On the next start needing_import finds that same original again and tells the player to import it, despite the converted copy already being present.
Do: Make the workflow remove or identify the original after a successful import, or tell the player explicitly to remove the original folder after verifying the imported mod.
@ -56,1 +58,3 @@&& std::fs::read_dir(dir).is_ok_and(|r| {if dir.join(api::manifest::file::NAME).exists() {return false;}L1 (blocking): Discovery stops at an emulator mod and never searches it for patch sets elsewhere in the same pack.
When: For a folder containing both romfs/ and atmosphere/exefs_patches/fps/e0.ips, find returns the folder immediately. convert copies romfs and lists the patch as left out, so the command succeeds without importing the patch set.
Do: Discover nested patch sets independently of an enclosing emulator-layout mod, and add a command-level test for a pack with root romfs and a patch set.
@ -127,6 +134,7 @@ pub fn convert(dir: &Path, name: Option<&str>) -> Result<Converted, OpError> {let slug = slug(&name);L2 (blocking): Patch sets are assigned destination IDs solely from their final folder name, without detecting collisions before import writes them.
When: Two sets named fps under different packs both become local/fps. import_found writes the first and then write_files removes its destination for the second; it reports both imports as successful, but only the second patch remains. An existing local/fps mod can likewise be deleted.
Do: Preflight destination IDs and existing mods before writing; refuse collisions or give each set a distinct ID with an explicit replacement policy.
5713213519f709e175caRebased onto main @
3a0f7d8f7for the base conflict; here @f709e175c. Tested (the game again on this head),mise run test(against main @3a0f7d8f7: every failure also fails on main) and Measurements are updated. Answers to the review below.L1
Fixed in
f709e175c.import::findnow goes on looking inside an emulator mod's folder for patch sets (only patch sets,and not in that mod's own
romfs/,exefs/orcheats/), whether the mod is the folder given or one found in it.The set is imported as a mod of its own, and the enclosing mod's left-out list no longer names its files. Test:
a_pack_with_a_root_romfs_and_a_patch_set_imports_both(modtool, through theimportop, with the pack given and withits parent given). Before the fix it failed with only
local/packimported.L2
Fixed in
f709e175c.import_foundnow works out every found mod's id before it writes anything (import::id_of, theid
convertgives). When two would share one, the import is refused (refused, nothing written), naming both foldersand saying to import each folder alone, with
--namefor one. A mod already in the profile keepsmain's policy, nowstated: an import over the profile's mod of the same id (an earlier import of it, or the folder itself) takes its
place, and drops its grants when the files differ. The result has
replaced, the text line says "replacing theprofile's mod of that id", and
docs/modding/tools.mdandmod-ops.mdsay so. I didn't refuse an existing id,because two things on
maindepend on importing over one. A re-import updates its mod:import_founddrops thegrants when the files differ. And importing a folder of
mods/takes over that folder's own id, whicha_copied_mod_is_written_down_off_switched_by_enable_and_on_once_imported_or_addedtests. Test:two_sets_of_one_name_are_refused_before_anything_is_written. Before the fix the import returnedboth sets as
local/fpsand kept only the second.L3
The warning itself went with the rebase: #3137 removed
mod_layoutandmod_needs_import, so this pull request nolonger adds patch sets to it. The same problem held for the set's Mods tab note, which this pull request keeps, so I
fixed it there in
f709e175c. At the start the loader checks whether a manifest mod has the set's patch files, byte forbyte, under the names import gives them (
code_mods::patch_set_files, compared bypatch_hash, the same waymainrecognises a plain mod's converted copy). If one does, switched on or not, the note says "Imported: another mod has
these patch files (its converted copy), and they are built in from that one. This folder can be removed." instead of
telling the player to import it. Test:
an_imported_patch_set_says_so_and_not_to_import_it(api). Before the fix thenote still said to import it.
L4
Rebased onto
main@3a0f7d8f7. #3137 builds a plain mod'sexefs/without import and removedmod_layoutand themod_needs_importwarning. This pull request's addition to that warning, and its testa_patch_set_needs_import, aredropped with it. The rest is ported onto
main's text: a patch set has noexefs/, so it still needs the import, andits Mods tab note stays.
In the game on this head (929bf025a, with the other ports merged): the patch set's row in the Mods tab once
local/rupee-counter-offholds its patch files.Merge note for #3165 and #3169: each passes alone on
main, but whichever merges second needs a one-line test fix. #3165 givesgame_files::patches::collecta refuse callback, and #3169's import test ingame/crates/modtool/src/import.rscalls it without one:collect(&nso, &mods, |_| Ok(()), &mut |l| said.push(l)). With all the mod compatibility ports merged together, that is the only change it needed there.@review
Recommendation: Approve. The patch-set import and collision fixes address the reported cases, and the obsolete warning was removed with the rebase. The imported-set note still overstates whether the patches are built in, but that wording issue does not block the feature. Recommend approval; not approved on the forge.
Players can import Atmosphere patch sets as code mods and see whether a matching copy exists. Discovery and collision checks add some import-time work but no per-frame work.
Should fix (1): not blocking, but worth doing before merging.
game/crates/api/src/loader/mod.rs:3287: The imported-set note says the patches are built in even when the matching mod's code has not been accepted or built. (more on the line) Do: Say that the matching mod contains the patches and direct the player to its row for acceptance and build status, or derive the built-in claim from that mod's actual status.@fixcan do L5.Since the last review (on
5713213519)Resolved: L1 (Discovery stops at an emulator mod and never searches it for patch sets elsewhere in the s…); L2 (Patch sets are assigned destination IDs solely from their final folder name, without detec…); L3 (The new warning treats the original patch set as unimported even after import succeeds.); L4 (It conflicts with its base branch: bring it up to date (
@​fixor@​rebasetry first).)New: L5 (The imported-set note says the patches are built in even when the matching mod's code has…)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes. The author reports that the patch removed the rupee counter in game on Windows, and that the new discovery, collision, and status tests pass after failing before their fixes. This is not a performance change.
Other systems: Import and loader behavior also affect Linux and archive inputs. The reported game run was on Windows; the patch-set tests exercise the import and loader logic without the game.
Switches: None.
Reviewed:
f709e175caagainst3a0f7d8f7f: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the diff, and the relevant import, service, loader, and code-mods paths. The full changed files and all dependent paths were not read in full; the diff output was truncated. The adjacent Tooling rules were unavailable, and docs/review-checklist.md does not exist.; nothing run (a code review).Checked and fine:
Testing: No commands from the project were run. The author reports a game run on Windows and local checks against the base; CI is still running.
Overlaps and merge order: #3165 changes the patches::collect signature; whichever pull request merges second needs the one-line test call adjustment described by the author.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -3262,0 +3284,4 @@} else if exefs && unconverted_patch_set(&r.path) {// (no exefs/ of its own: the build does not read the folder; import copies the files into a mod's)note.push_str(if r.copied {"Imported: another mod has these patch files (its converted copy), and they are built in from that one. This folder can be removed."L5 (should fix): The imported-set note says the patches are built in even when the matching mod's code has not been accepted or built.
When: After importing a patch set but before accepting its code, code_status records the matching manifest's patch hash regardless of acceptance, so the original set's row says the patches are built in although the builder holds them.
Do: Say that the matching mod contains the patches and direct the player to its row for acceptance and build status, or derive the built-in claim from that mod's actual status.
@fix
f709e175cab81d0a33e2Recommendation: Approve. The revised note no longer claims that a matching mod’s patches are built in before acceptance and build status are known. The base-to-head diff includes substantial additional changes that were not fully reviewed, and the import test needs the #3165 callback adjustment. Nothing blocking is left. Recommend approval; not approved on the forge.
What
@fixchangedI changed this pull request: the new head is
b81d0a33e2. I rebased it ontomain(296209f543).Conflicts resolved
Changed
Nothing was built or run: the checks run again on the new head.
The change imports Atmosphere patch sets as ExeFS mods and explains their status in the Mods tab. The latest fix directs players to the matching mod’s row for acceptance and build status.
Checks: they run again on this head; a failure shows on the pull request.
Also noticed (3; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes: the reported Windows game run showed an imported patch taking effect, and the reported tests cover discovery, conversion, duplicate IDs and the row note. The revised note itself has not been run.
Other systems: Import and patch discovery affect Windows and Linux; the reported game run is on Windows. The note does not depend on GPU-specific behavior.
Switches: None added, changed or removed by the patch-set change.
Reviewed:
b81d0a33e2against296209f543: Read the repository rules and pull request template, the fix diff, the changed note and its test, and the surrounding copy-detection logic. Skimmed the patch-set import code and feature diff. The base-to-head diff contains 588 files, including changes beyond the 15 listed for this pull request; those files were not all read.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run tests were executed. The author reports Windows game and test results; CI has not run on this head.
Overlaps and merge order: #3165 changes patches::collect and is already present in the current ancestry; the import test needs its additional callback.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.