feat(mods): a mod can ask to load last with order = "last" #3192
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 project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3192
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:feat/mod-order-last"
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
A mod that has to come after mods it cannot name, such as the one the randomizer generates for each seed, had no way to say so: players had to move it to the bottom of the list themselves, and dependencies cannot help (and do not decide which mod wins a file).
A mod can now put
order = "last"in itsmod.toml:An older Longshot ignores the field. An add-on that replaces files of such a mod has to ask to load last too and sit below it, since which mod wins a file is the list's order alone.
Read first:
game/crates/api/src/loader/mod.rs(put_last,move_to),loader/arrive.rs(a mod added while the game runs),loader/resolve.rs(step 6),modtool/src/service.rs(order),builder/crates/game-files/src/code_mods.rs(put_last). The docs' note that the launcher has its own resolver was out of date and is replaced. The launcher's tag and note are a separate pull request in LongshotLauncher.Testing
Tested: Linux, RTX 3090, driver 620.70.06, a headless run from
kokiri-startof two file mods replacing the same path, the one asking to load last listed first. The log loaded it second (as the upper layer), the Mods tab showed it below the other with Loads last and the note under the list, and no FATAL or unhandled exception. The path is a made-up one the game never opens, so which copy is served is checked by the tests, not by that run. That run was made on an earlier head. On896ebe00, a second headless run of the same two mods loaded the one that asks last second, and its Mods tab showed the tag, the order and the new note; the same run onmainshowed the listed order with neither (screenshots). The ordering fixes after that run (a mod added mid-game, the builder's patch order,orderread from the copy that loads) have run in their tests, not in the game.New tests: the loader (order, moves, a mod added while the game runs, with the served file),
mod order, the builder's patch order, the Mods tab, and cases in the manifest and resolver vectors.Checks: the Rust checks as
mise run rustruns them, on the base one commit before the head's (that commit is a renderer change): rustfmt,schema-gen --checkandffi-gen --checkpass;cargo test -p modtool274 passed, 0 failed; the rest of the workspace 3486 passed, 4 failed. The 4 and Clippy's one error also fail onmain(f8b54338):build-driver'sthe_repository_s_lock_and_the_table_agree,longshot-builder'sone_copyinstalled_versions_reuse_their_own_builds_with_one_profile,net-broker'senginetestslocal::a_local_endpoint_carries_bytes_both_waysandlocal::local_endpoints_are_refused_by_the_grant_the_build_and_the_caps, and Clippy's "large array defined as const" inhost-sys/src/settings_abi.rs. Clippy stops there, so it did not lint the crates afterhost-syson this base.mise run test, on an earlier base: 885 passed, 6 failed, each also failing onmain:test_dlssg.py,test_lifter.py,test_no_game_title.py,test_sync_watch_event.py,test_turf_budget.py,test_vk_draw_overhead_lean.py.Still to test:
order = "last"and another replacing the same file in a profile, open the Mods tab, expecting the first at the bottom with its tag, and no drag or Ctrl+Space move taking another below it (by hand).mods/while it runs, expecting it above the mod that loads last (by hand).Measurements
Nothing to measure: it adds one sort of the mod list at a start and when a mod arrives or the builder reads the profile, and a line of text in the Mods tab.
Risks
profile.json.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand here, for a change that shows on screen.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: Linux, RTX 3090, driver 620.70.06, headless from kokiri-start with two file mods replacing the same path: the one with order = "last", listed first, loaded as the upper layer and showed at the bottom of the Mods tab, tagged Loads last, with the load-order note under the list. No FATAL or unhandled exception. Run before the last two rebases and the fix for mods added while the game runs.
Possibly related, for context:
@review
Recommendation: Request changes. The displayed order can disagree with the order used for ExeFS patches, and adding a normal mod during play can prevent live file updates. Some copies can also be classified using a manifest the loader will not select.
Adds a manifest field that groups mods at the bottom of the list, changes resolver priority, and labels them in the Mods tab. The feature has useful tests, but its ordering is not consistent across all loading paths.
Blocking (3): must change before merging.
game/crates/api/src/loader/arrive.rs:441: Sorting the rows after appending the new entries leaves start_rows in the old order, so the loader treats the live order as a pending user reorder. (more on the line) Do: Keep start_rows in the same effective order as the rows after a live arrival, and test the real hot-layer rebuild and subsequent edits.builder/crates/build-driver/src/read.rs:30: The stable last-group sort preserves the concatenation of manual and source mods, not their profile order. (more on the line) Do: Combine both sources in profile order before applying the last-group ordering, and test overlapping patches from both installation types.game/crates/api/src/loader/mod.rs:1826: The manifest used to classify a row is chosen without the resolver's copy-shadowing rules. (more on the line) Do: Classify the same eligible copy that resolution selects, including shadowing and version pins; cover conflicting copies in a loader test.Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
@fixcan do L1, L2 and L3.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven: the reported Linux run showed the list and label, but used a path the game never opened and predates the final live-arrival fix. Tests cover several ordering cases.
Other systems: The builder, source-installed and manual mods, live file layers, dependency resolution, the Mods tab and modtool all use the changed ordering. Windows and the final live-arrival path still need a run; no GPU-specific behavior is apparent.
Switches: None.
Reviewed:
c62ef3e272againsta87eb85099: Read the repository rules and PR template, the diff, commit messages, and the relevant loader, builder and profile paths. Skimmed translations, vectors and generated schema changes; not every changed code file was read in full.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no builds, tests or project scripts were run. CI is still running.
Overlaps and merge order: Not checked; network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -27,6 +27,7 @@ pub fn manifest_mods(profile: Option<&Path>, log: &mut dyn FnMut(String)) -> Ressource_mods_whole(&cache, p, log)?;mods.extend(modtool::profile::store_code_mods(&cache, p, log));}game_files::code_mods::put_last(&mut mods);L2 (blocking): The stable last-group sort preserves the concatenation of manual and source mods, not their profile order.
When: If a source-installed last mod is above a manual last mod in the profile and both patch the same byte, exefs_mods puts the manual mod first and store_code_mods appends the source mod. The source patch wins even though the displayed lower manual mod should win.
Do: Combine both sources in profile order before applying the last-group ordering, and test overlapping patches from both installation types.
@ -434,2 +438,4 @@self.start_rows.push((id, key));}// (a mod that joined goes above those that load last, as at a start: their files stay theirs)self.rows.sort_by_key(|r| r.loads_last);L1 (blocking): Sorting the rows after appending the new entries leaves start_rows in the old order, so the loader treats the live order as a pending user reorder.
When: With a live last mod, a normal mod arrives and is sorted above it, while start_rows still has the new mod after it. layers_changed then remains true, causing hot_files and hot_layers to hold file changes until restart.
Do: Keep start_rows in the same effective order as the rows after a live arrival, and test the real hot-layer rebuild and subsequent edits.
@ -1818,0 +1823,4 @@/// Whether the copy of `id` the start would take (`pin`ned, else the newest) asks to load last.fn asks_last(&self, id: &str, pin: Option<&str>) -> bool {let copies = self.found.iter().filter(|f| f.id == id && !f.system).filter_map(|f| f.manifest.as_deref());let pin = pin.and_then(|v| Version::parse(v, false));L3 (blocking): The manifest used to classify a row is chosen without the resolver's copy-shadowing rules.
When: When an ID has a copy at its canonical mods/owner/name location and a newer copy elsewhere, copy_left_out selects the canonical copy, but asks_last selects the newest. If their order fields differ, the row and file precedence use the other copy's setting.
Do: Classify the same eligible copy that resolution selects, including shadowing and version pins; cover conflicting copies in a loader test.
c62ef3e272896ebe0051The Mods tab at the same spot, with two made-up file mods, "Rando test" (
order = "last") listed first in the profile and "Other test". Linux, RTX 3090, driver 620.70.06, headless fromkokiri-start.main(46ae5b43), which ignores the field:This branch (
896ebe00):WIP: feat(mods): a mod can ask to load last with order = "last"to feat(mods): a mod can ask to load last with order = "last"Recommendation: Request changes. Live arrivals can be mistaken for a pending reorder, builder patch order can disagree with the profile, and row classification can use a shadowed manifest. These can change which mod’s files or patches win.
Mods can request a last-loading group while players retain order within each group. The feature addresses an ordering need, but the loader and builder still disagree in the cases covered by the open items.
Blocking (3): must change before merging.
game/crates/api/src/loader/arrive.rs:441: Sorting the rows after appending the new entries leaves start_rows in the old order, so the loader treats the live order as a pending user reorder. When: With a live last mod, a normal mod arrives and is sorted above it, while start_rows still has the new mod after it. layers_changed then remains true, causing hot_files and hot_layers to hold file changes until restart. Do: Keep start_rows in the same effective order as the rows after a live arrival, and test the real hot-layer rebuild and subsequent edits.builder/crates/build-driver/src/read.rs:30: The stable last-group sort preserves the concatenation of manual and source mods, not their profile order. When: If a source-installed last mod is above a manual last mod in the profile and both patch the same byte, exefs_mods puts the manual mod first and store_code_mods appends the source mod. The source patch wins even though the displayed lower manual mod should win. Do: Combine both sources in profile order before applying the last-group ordering, and test overlapping patches from both installation types.game/crates/api/src/loader/mod.rs:1826: The manifest used to classify a row is chosen without the resolver's copy-shadowing rules. When: When an ID has a copy at its canonical mods/owner/name location and a newer copy elsewhere, copy_left_out selects the canonical copy, but asks_last selects the newest. If their order fields differ, the row and file precedence use the other copy's setting. Do: Classify the same eligible copy that resolution selects, including shadowing and version pins; cover conflicting copies in a loader test.Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
@fixcan do L1, L2 and L3.Since the last review (on
c62ef3e272)Still open: L1 (Sorting the rows after appending the new entries leaves start_rows in the old order, so th…); L2 (The stable last-group sort preserves the concatenation of manual and source mods, not thei…); L3 (The manifest used to classify a row is chosen without the resolver's copy-shadowing rules.); L4 (The final live-arrival behavior and the visible controls need an in-game check.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven: the reported Linux run shows the tag and initial ordering on this head, but the live-arrival behavior and visible controls still need the in-game check.
Other systems: The change affects runtime file layers, dependency ordering, the builder’s ExeFS patch order, the Mods tab and modtool. Windows controls and live arrival remain untested in game.
Switches: Adds the optional manifest field order = "last"; omitted by default. It is a mod-author declaration, and the documentation describes its effect.
Reviewed:
896ebe0051against46ae5b43d3: Read AGENTS.md and CONTRIBUTING.md; inspected the loader ordering, arrival and resolver code, builder ordering paths, their diffs, and the reported runs. The remaining changed files, translations, vectors and generated schema were not read in full.; nothing run (a code review).Checked and fine:
Testing: The author reports a Linux headless run on this head and passing targeted tests. Windows move controls and adding a mod during a running game remain to be checked; CI is still running. No tests were run in this review.
Overlaps and merge order: The description identifies a separate LongshotLauncher pull request for its tag and note; no merge order is stated.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as HumanBean took it out of WIP. Nothing was run; a maintainer decides.
896ebe00513dc8e1ee283dc8e1ee285db676713f@review
Recommendation: Approve. The code is ready: only testing is left (a run of the change itself). The ordering fixes address the three code issues, and the initial load order and Mods tab were shown working on Linux. Live arrival and the move controls still need an in-game check. Recommend approval; not approved on the forge.
Mods can request a last-loading group while players retain ordering within each group. The follow-up keeps live-arrival baselines aligned, orders builder patches by the profile, and classifies the copy the resolver selects.
Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
Since the last review (on
896ebe0051)Resolved: L1 (Sorting the rows after appending the new entries leaves start_rows in the old order, so th…); L2 (The stable last-group sort preserves the concatenation of manual and source mods, not thei…); L3 (The manifest used to classify a row is chosen without the resolver's copy-shadowing rules.)
Still open: L4 (The final live-arrival behavior and the visible controls need an in-game check.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven for the full feature: the reported Linux run showed initial ordering, the tag and the note; live arrival and move controls have not been checked in game. This is not a performance change.
Other systems: The loader affects live file layers and the Mods tab; the builder also uses the ordering for ExeFS patches. The reported run covers initial behavior on Linux, while the remaining integrated behavior has not been run.
Switches: None.
Reviewed:
5db676713fagainstf8b543384d: Read the changed builder ordering code and the loader arrival, baseline and copy-selection paths; inspected the fix diff, related tests, repository rules, PR template, description and reported runs. The rest of the original PR diff, translations and generated files were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands from the project were run. The author reports Linux in-game initial-order coverage and game-free tests; CI is still running. Check live arrival and the move controls in game before merge.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
L1 to L3 are fixed in
5db67671, each with a test (L1's and L3's failed before the fix). L4 is not done: the final head has not added a mod during play in the game, and nothing has run on Windows. Both are under Still to test.