Skip to content

fix: long data roots, coremod providers and failed-import cleanup (v0.29 regression findings) - #549

Merged
AntonBabchenko merged 6 commits into
mainfrom
fix/v029-regression-findings
Nov 6, 2026
Merged

AntonBabchenko merged 6 commits into
mainfrom
fix/v029-regression-findings

Conversation

@AntonBabchenko

Copy link
Copy Markdown
Owner

What

Three defects the v0.29 regression pass found (none introduced by v0.29), plus the refusal's wording:

  • F1 — a long data root turned a pack import into a path "escape". Every inside/overlap check resolved both
    sides with dunce::canonicalize. dunce strips Windows' \\?\ prefix only when it can (under MAX_PATH, a local
    drive, no reserved name), so a short .minecraft and a long child never shared a prefix: on a 161-character data
    root RLCraft was refused with "overrides entry tried to escape the instance directory". Born v0.5.0.
  • F3 — every RLCraft profile read as unable to start. TNTUtils requires tnt_utilities_core, which its own jar
    provides through a coremod's mod container; the ≤ 1.12.2 pre-flight did not read containers, so the Overview said
    «Игра не запустится» and feat(modpacks): finish a pack whose files Lucerna can't download #548's Play gate added a false row.
  • F2 — a failed import left its half-made profile in the list and on disk while the toast said the import failed.
  • The path-escape refusal said "Запись overrides сборки попыталась выйти за пределы директории профиля" — internal
    words. It now says Lucerna did not touch the file because its path leads outside the profile's folder, that this
    happens when a pack is damaged or built with a mistake, and what to do.

How

  • pathsafe::ResolvedPath (std canonicalize) compares only with another ResolvedPath (is_within,
    join_unresolved), so mixing a resolved and a raw path no longer compiles. Moved onto it: overrides extraction,
    asset install/removal, hand-installed packs, the transfer overlap check, the Java exclusion of Lucerna's own
    runtimes. The asset-removal check no longer uses exists() (NotFound skips, any other error refuses).
    tests/structural_no_dunce_compare.rs fails on any mention of dunce outside java/detect.rs (display only).
  • The legacy reader follows FML: manifest FMLCorePlugin → what the plugin's getModContainerClass() code loads
    (one class; a string or a class literal) → the String the container's constructor stores straight into
    ModMetadata.modId/.version. A store on a jump target (a ternary) is skipped; method code outside JVMS's
    1..=65535 bytes or a plugin/container that cannot be read is "could not tell" (never cached). New
    DescriptorSource::CoremodContainer, ranked like the annotation, kept out of same_mod::loader_ids (jar identity
    unchanged). jar_scan_cache::SCHEMA_VERSION 2 → 3.
  • install_resolved_pack: the work after create_instance runs in one async block; a returned error removes the
    instance (refused like any removal while a game runs or a maintenance holds it), naming::DirCleanup covers a panic
    or a dropped future, and a removal that fails returns the new ModpackImportLeftover naming the folder. A partial
    failure keeps the instance, as before.

Fallback discipline

  • Direction: an unreadable coremod part is "could not tell", not "provides nothing"; a removal check that cannot
    resolve the parent refuses.
  • Discrimination: NotFound vs other errors at the asset-removal check and the Java exclusion.
  • Honesty: the escape copy says what happened in plain words; a leftover profile is named with its folder.
  • Recovery path: the failed import's own cleanup is checked; its failure is reported (ModpackImportLeftover) and
    logged with both errors.

Tests

  • Red first: the long-path extraction test (fails on the old code at the expect), the dunce guard (12 lines on the
    old tree), the coremod tests and dependency_preflight::legacy_requirement_met_by_its_own_jars_coremod_container
    against a naive stub, the leftover decision against a stub; two mutations (ignore jump targets, read candidates from
    every plugin method) caught exactly the four negative tests predicted.
  • Fixtures: javac-compiled (JDK 17, --release 8) plugin/container classes of both eras, shaped like TNTUtils'
    TntuPlugin/TntuCoremodContainer; existing fixtures recompile byte-identical.
  • Local green: 212 lib tests in the touched modules, dependency_preflight 15, 24 structural guards (bare rustc; the
    two that need serde_json are CI's), Vitest 326 (format-error, changelog-parity, i18n parity + every-locale),
    typecheck 0 errors, Biome/Prettier/no-network clean.
  • Spec audited adversarially before code; one code review on the commit range — its MUST (code-length bound,
    quadratic target lookup) and SHOULDs (constructor-only scan, comments, quote style, changelog lead) are in.

Live check (dev build, own identifier, 161-character Cyrillic data root — the maintainer's data untouched)

  • RLCraft 2.9.3 CurseForge zip imports; the deep config/roguelike_dungeons/… file lands (395-character path).
  • Installed RLCraft: Overview «Готово к игре»; Play gate lists only the two manual files, no tnt_utilities_core.
  • A .mrpack whose override is ../escape.txt: import fails with the new copy; no profile is left in the list
    or on disk.
  • ModpackImportLeftover (a removal that fails) — unit-tested only; could not be induced live.

Changelog: two Fixed bullets, EN + RU at the same position.

…n escape

Every inside/overlap check resolved both sides with dunce::canonicalize. dunce
strips Windows' \?\ prefix only when it can (a path under MAX_PATH on a local
drive, no reserved name), so a short .minecraft and a long child never shared a
prefix: on a 161-character data root, importing RLCraft was refused with
"overrides entry tried to escape the instance directory" (v0.29 regression
pass, F1). Born v0.5.0.

pathsafe::ResolvedPath resolves with std::fs::canonicalize and compares only
with another ResolvedPath (is_within, join_unresolved), so mixing a resolved and
a raw path no longer compiles. Moved onto it: overrides extraction, asset
install and removal, hand-installed packs, the transfer overlap check, the Java
exclusion of Lucerna's own runtimes. The asset removal check no longer uses
exists(): NotFound skips it, any other error refuses. Detection keeps dunce only
for the Java home it shows.

tests/structural_no_dunce_compare.rs fails on any mention of dunce outside that
one file (red on the old tree: 12 lines).
On Forge <= 1.12.2 a coremod (FMLCorePlugin in the manifest) registers a mod
container: FML loads the class getModContainerClass() returns under the
ModMetadata.modId it assigns. TNTUtils (RLCraft) requires tnt_utilities_core,
which its own container provides; the pre-flight did not read containers, so
every RLCraft profile read as unable to start and the Play gate listed it
(v0.29 regression pass, F3).

The legacy reader now follows FML: the plugin's getModContainerClass() code
(an ldc of a class name or a class literal; more than one candidate names
nothing), then the container's String stored straight into ModMetadata.modId
/ .version. A store on a jump target (a ternary) is skipped. A plugin or
container that exists but cannot be read makes the jar "could not tell", never
a cached "provides nothing".

The provider is a new DescriptorSource::CoremodContainer, ranked like the
annotation; same_mod::loader_ids leaves it out, so jar identity does not move.
jar_scan_cache SCHEMA_VERSION 2 -> 3 rebuilds cached legacy scans.

Fixtures: javac-compiled (JDK 17, --release 8) plugin/container classes of both
eras, shaped like TntuPlugin / TntuCoremodContainer.
install_resolved_pack created the instance, then returned early with ? from
four places (instance_dir, app_dir, the world snapshot, overrides extraction);
nothing removed it, so a profile the toast said was never imported stayed in
the list (v0.29 regression pass, F2).

The work after create_instance runs in one async block. A returned error
removes the instance (refused like any removal while a game runs or a
maintenance holds it); a panic or a dropped future is covered by
naming::DirCleanup. When the removal fails, the import returns the new
ModpackImportLeftover naming the folder left on disk, with the import's own
failure as the detail. A partial failure is unchanged: the instance stands.
…ctors

Review follow-ups on the coremod container reader:
- a Code attribute outside JVMS 4.7.3's 1..=65535 bytes is "could not tell":
  a crafted multi-megabyte method would cost one decoded instruction each;
- jump targets are a HashSet, so a long method of branches and stores is not
  quadratic;
- only <init> is searched for the ModMetadata stores: a store in another
  method may never run, or fill a second ModMetadata.
Plus two comments: the leftover error's details are the cause's Display text,
and the long-path extraction test is red only on Windows.
"Modpack overrides entry tried to escape the instance directory" named an
internal folder and read like an attack report. The refusal now says what
Lucerna did, why, and what to do: it did not touch the file because its path
leads outside the profile's folder, which happens when a pack is damaged or
built with a mistake; download it again or tell its author. The leftover
error's English copy uses straight quotes like its neighbours, and the second
changelog bullet's lead is reworded.
@AntonBabchenko
AntonBabchenko merged commit 3befbf6 into main Nov 6, 2026
12 checks passed
@AntonBabchenko
AntonBabchenko deleted the fix/v029-regression-findings branch November 6, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant