From 862f4d19becac81fc34ec223a1bd5b8f9acb0b3d Mon Sep 17 00:00:00 2001 From: piexel Date: Mon, 5 Oct 2026 18:02:31 +0200 Subject: [PATCH] Document module names, duplicate classes and the load summary Drop version gating as an open question: packs ship their module jars and nothing is downloaded, so compatibility is the pack publisher's responsibility. Describe the duplicate-class rule including multi-release jars, the per-pack log summary, and the adapter's job of routing System.Logger output. --- CONTRACTS.md | 7 +++++-- DESIGN.md | 40 +++++++++++++++++++++++++++++----------- README.md | 29 +++++++++++++++++++++++------ 3 files changed, 57 insertions(+), 19 deletions(-) diff --git a/CONTRACTS.md b/CONTRACTS.md index aeac0cfa4..67cb8d2da 100644 --- a/CONTRACTS.md +++ b/CONTRACTS.md @@ -28,6 +28,9 @@ types that carry them and lists what the Iris adapter still owes. Stage bodies hold no invocation state. Everything per placement or chunk travels through the context, outputs and accumulators. +There is no API version gating. Packs ship their module jars, so their compatibility with the +running Iris is the pack publisher's responsibility. + ## Requirements for the Iris adapter - Port the engine as ordinary modules. Keep `iris:*` stage ids stable once packs or addons @@ -42,6 +45,8 @@ context, outputs and accumulators. - Preserve unknown persisted mantle layers or fail explicitly. - Load each pack's jars with `PackModules`, pass them with the built-in modules to `LoadedModules.load`, and close `PackModules` only after nothing built from it is in use. +- Route `System.Logger` output (logger `com.volmit.host.PackModules`) to the server log, so the + per-pack module summary is visible. - Make built-in modules visible to the loader that defines the API, or pack jars cannot require their stages. @@ -50,5 +55,3 @@ context, outputs and accumulators. - Per-stage reach declarations, replacing the removed modifier radii. - Per-stage RNG streams, so adding a module does not shift other modules' random draws. - Terrain/biome providers, pack transformations, structure assembly and the runtime family. -- Version gating: modules do not declare which API version they target, so an incompatible jar - fails with a linkage error at load or later at install or run time. diff --git a/DESIGN.md b/DESIGN.md index aba21b6b9..95894872d 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -33,9 +33,9 @@ flowchart TD ## Module loading -The `IrisModule` implementation is the module's entry point. `info()` returns its id and -version; there is no separate descriptor. A pack keeps its modules in `/modules/*.jar`, -one module per jar. +The `IrisModule` implementation is the module's entry point. `info()` returns its id, display +name and version; there is no separate descriptor. A pack keeps its modules in +`/modules/*.jar`, one module per jar. A jar names its entry class in `META-INF/services/com.volmit.IrisModule`, the provider format of `ServiceLoader`. The host reads that file from the jar itself rather than calling @@ -52,17 +52,30 @@ which jar a broken provider came from. The rejected alternatives: 1. Lists regular files ending in `.jar` in `/modules`, sorted by file name. A missing directory means no modules. -2. Reads each jar's entry point file. Comments (`#`) and blank lines are ignored; zero or more - than one class name fails. -3. Creates one `URLClassLoader` for all jars of the pack, parent = the loader of `IrisModule`. -4. Loads each entry class, checks that it implements `IrisModule` and comes from its own jar, +2. Reads each jar's entry point file and its class names. Comments (`#`) and blank lines are + ignored; zero or more than one entry class name fails. +3. Fails if a class is in two jars, naming the class and both jars. Nothing has been defined yet. +4. Creates one `URLClassLoader` for all jars of the pack, parent = the loader of `IrisModule`. +5. Loads each entry class, checks that it implements `IrisModule` and comes from its own jar, instantiates it with the public no-argument constructor and calls `info()`. +6. Logs one INFO summary of the pack's modules. One loader per pack, not per jar, because `requires(...)` takes another module's stage constant. A pack jar that requires a stage of another pack jar must see its classes. Packs stay isolated from each other, and built-in modules visible to the API's loader are visible to every pack. The -cost: two jars of one pack that contain the same class name share the first one in file name -order. The entry-class check catches this for entry classes only. +cost is a shared class namespace: with two copies of a class, the loader would silently use the +one first in file name order. Step 3 turns that into a load error, so two jars that shade the same +library must relocate it, and shared code belongs in one module that the others require. + +The class check reads jars the way the loader does. `module-info.class` is ignored. A +multi-release jar (`Multi-Release: true`) contributes each class once, under its base name, from +the highest `META-INF/versions/N` that the running JDK selects; a versioned copy of a class in one +jar therefore clashes with the plain class in another. In a jar without that manifest attribute the +loader never reads `META-INF/versions`, so those entries are skipped. + +There is no version gating. Packs ship their module jars and Iris never downloads any, so whether +a jar works with the running Iris is the pack publisher's responsibility. An incompatible jar +fails with a linkage error at load, install or run time. Closing `PackModules` closes the loader. Classes loaded before that keep working, so the host must drop `LoadedModules` and everything else built from the pack first. @@ -71,6 +84,11 @@ Each module reaches `LoadedModules.load` as a `DiscoveredModule`: the module and jar path relative to the pack or "host classpath" for built-ins. Duplicate module ids and foreign stage namespaces name the origin. Every jar error names the jar. +The load summary goes through `System.getLogger(PackModules.class.getName())`, so the host can +route it with a `System.LoggerFinder`. It lists display name, id, version and jar for each module +in load order, or says the pack has no module jars. `PackModulesSummary` builds the text and is +tested on its own. + ## Stages A stage is a constant created by `Stage.placement`, `Stage.placementBlock` or `Stage.chunk`. Its @@ -197,8 +215,8 @@ Unknown persisted layers must be preserved or fail explicitly. ## Not implemented -- Iris host wiring: version gating, JSON decoding and validation, schema generation, resource - loaders, platform block adapters, storage and codecs. +- Iris host wiring: JSON decoding and validation, schema generation, resource loaders, platform + block adapters, storage and codecs. - Reach. The old per-modifier `writeRadius` and `mantleRadius` are gone with the modifiers. The host must prepare the whole area a pipeline may touch. Per-stage reach is an open question. - Legacy random compatibility. Seed offsets and draw order must be matched by the adapter where diff --git a/README.md b/README.md index d8d9656d8..9a8e81efc 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ them in `install`. Other modules order themselves against those constants. public final class MossModule implements IrisModule { public static final PlacementStage SPREAD = Stage.placement("example:moss/spread"); - public ModuleInfo info() { return ModuleInfo.of("example:moss", "1.0.0"); } + public ModuleInfo info() { return ModuleInfo.of("example:moss", "Moss", "1.0.0"); } public void install(StageGraph graph) { graph.define(SPREAD) @@ -55,8 +55,13 @@ modules/moss.jar com/example/moss/MossSettings.class ``` -`info()` gives the module id and version. The id's namespace is the namespace of every stage the -module defines. +`info()` gives the module id, display name and version. The id's namespace is the namespace of +every stage the module defines; the name is what logs show. A class may appear in only one jar of +a pack, so shaded libraries need relocating. + +Iris never downloads modules and does not check which API version a jar was built for. A pack +ships its module jars, and keeping them compatible with the Iris version it targets is the pack +publisher's job. ## Host side @@ -76,8 +81,19 @@ try (var pack = PackModules.load(packRoot)) { `PackModules.load` reads one entry point per jar, in jar file name order, and loads every jar of the pack through one class loader. Closing it closes that loader. A pack without a `modules` -directory has no modules. Errors name the jar: no entry point, several entry points, or an entry -class that cannot be loaded, is not an `IrisModule`, is not in that jar, or fails to construct. +directory has no modules. Errors name the jar: no entry point, several entry points, a class that +is also in another jar of the pack (both jars are named), or an entry class that cannot be loaded, +is not an `IrisModule`, is not in that jar, or fails to construct. + +A successful load logs one INFO summary through `System.Logger`: + +``` +Pack overworld uses 2 modules: + Moss (example:moss 1.0.0) from modules/moss.jar + Stilts (iris:stilt 2.1.0) from modules/stilt.jar +``` + +A pack without jars logs `Pack overworld uses no modules: no jars in its modules directory`. `LoadedModules.load` installs every module, catalogs the settings types named in `when(...)` together with geometry and mantle registrations, and resolves both pipelines. Graph errors @@ -112,7 +128,8 @@ invocations and must not keep views or mutable state. The tests cover graph resolution and every error path, fusion, activation cascade, outputs, rejection and rollback, and install-order determinism. `PackModulesTest` compiles real module -jars into a temporary pack and loads them, including every jar error. The example ports in +jars into a temporary pack and loads them, including every jar error and duplicate classes in +plain and multi-release jars. `PackModulesSummaryTest` checks the log text. The example ports in `src/test/java/com/volmit/example` rebuild preparation, anchoring, block writes, stilt and snow as separate modules, add a third-party moss module, and add a two-module chunk pipeline. There is no Minecraft integration or production storage in these tests.