From b82c292dcb2c4b18bdd3bc94f23245629fd0d94f Mon Sep 17 00:00:00 2001 From: piexel Date: Fri, 9 Oct 2026 23:16:52 +0200 Subject: [PATCH] Settings features declare a short JSON key and may declare a root option @Feature(key) is required: a plain field name, unique per target across all modules and the host's own JSON fields (ModuleHost.reservingFields, back for keys). A clash refuses the pack load naming the key, the target and both claimants. @Feature(root) declares that the JSON under the key is one option's value, so a settings class has exactly one shape; FeatureSchema carries it. --- CONTRACTS.md | 12 +- DESIGN.md | 40 +++++-- README.md | 37 ++++-- .../java/com/volmit/FeatureAttachment.java | 17 ++- src/main/java/com/volmit/config/Feature.java | 16 ++- .../com/volmit/host/FeatureDescriptor.java | 35 +++++- .../java/com/volmit/host/LoadedModules.java | 6 +- src/main/java/com/volmit/host/LoadedPack.java | 2 +- src/main/java/com/volmit/host/ModuleHost.java | 57 ++++++++-- .../java/com/volmit/host/ModuleRegistry.java | 99 ++++++++++++++-- .../com/volmit/host/PackSchemaBuilder.java | 2 +- .../com/volmit/host/schema/FeatureSchema.java | 23 +++- .../java/com/volmit/FeatureContractTest.java | 48 +++++++- .../com/volmit/example/ChunkPipelineTest.java | 4 +- .../example/PlacementLifecyclePortTest.java | 2 +- .../volmit/example/chunk/GrassSettings.java | 2 +- .../volmit/example/chunk/VeinSettings.java | 2 +- .../example/placement/MossSettings.java | 2 +- .../example/placement/SnowSettings.java | 2 +- .../example/placement/StiltSettings.java | 2 +- .../example/terrain/LayersSettings.java | 2 +- .../example/world/WorldStateExampleTest.java | 2 +- .../volmit/host/ConfiguredSettingsTest.java | 4 +- .../com/volmit/host/DiscoveredModuleTest.java | 2 +- .../com/volmit/host/LifecycleRunnerTest.java | 2 +- .../java/com/volmit/host/LoadedPackTest.java | 5 + .../com/volmit/host/ModuleRegistryTest.java | 107 ++++++++++++++++-- .../java/com/volmit/host/PackModulesTest.java | 46 ++++++-- .../java/com/volmit/host/PackSchemaTest.java | 63 ++++++++--- .../java/com/volmit/host/StageGraphTest.java | 12 +- 30 files changed, 536 insertions(+), 119 deletions(-) diff --git a/CONTRACTS.md b/CONTRACTS.md index 8784b0dcf..0e1fb5580 100644 --- a/CONTRACTS.md +++ b/CONTRACTS.md @@ -21,7 +21,7 @@ types that carry them and lists what the Iris adapter still owes. | Pack-load validation and diagnostics | host `StageGraphBuilder`, `ResolvedGraph`, `LoadedModules` | | Reference execution | host `PlacementRunner`, `ChunkRunner`, `MantleRunner` | | Work across chunks and mantle writes | `Stage.mantle`, `MantleStage`, `MantleStageContext`, `MantleGenerationContext`; chunk stages read the mantle only | -| Annotated settings | `IrisFeature`, `@Feature` (id as JSON key), config annotations, `OptionsMetadata` | +| Annotated settings | `IrisFeature`, `@Feature` (id, short JSON `key`, optional `root`), config annotations, `OptionsMetadata` | | Area a stage writes | `reach(blocks)`, `reach(PackReach)`, `writesMantle(...)` on stage definitions, `PackSettings`, host `StageReach`, `ResolvedStage.reachBlocks`, `PipelineReach` | | Settings described for studio | `@Desc`, `@Required`, `@MinNumber`, `@MaxNumber`, `@MinItems`, `@Snippet`, `@Ref`/`Reference`, `FeatureRegistry.registerSettings`, `FeatureRegistry.registerHeldType`, host `FeatureCatalog.heldTypes()`, host `LoadedPack.schema()` (`PackSchema`, `FeatureSchema`, `ObjectType`, `SchemaOption`, `ValueKind` with `HostKind`), `ModuleHost.describingHostTypesIn` | | Geometry and mantle registration | `FeatureRegistry`, host `ModuleRegistry`, `FeatureCatalog` | @@ -60,8 +60,9 @@ a working no-argument constructor, a bad or repeated snippet name, or a pack cla outside its module's folder. Defaults come from an instance made by that constructor. Options are in declaration order. -Packs write settings under the feature id, as the settings object; there are no aliases and no bare-value -shorthand. The description is in a fixed order and holds module entries only. +Packs write settings under the short key the feature declares, as the settings object, or as the value of the +one option its `root` names; there is no second form. A key is unique per target across modules and the host's own +JSON fields. The description is in a fixed order and holds module entries only. Modules compile against the API `compileOnly` and never ship it. At runtime they can use the API (`com.volmit.*`), the host packages the host chooses to expose, the JDK and the classes in their @@ -139,7 +140,10 @@ running Iris is the pack publisher's responsibility. packs and is part of what packs can break on. Stage output types and settings types that pack code uses through those stages must be in exposed packages too. The API is always exposed. - Consider showing `PackModules.missingClasses()` in studio. -- Decode module settings under the feature id, as a JSON object (or a snippet reference for a `@Snippet` type). +- Pass the host's own JSON fields per target to `ModuleHost.reservingFields(...)`, so a settings key can never + shadow one; a clash refuses the pack load. +- Decode module settings under the declared key, as a JSON object (or a snippet reference for a `@Snippet` type), or, + for a feature with a `root`, as exactly that option's value. Render one shape for each. - Render `pack.schema()` into studio's files: merge each target's `fields(target)` into the schema of the matching Iris file type (dimension, region, biome, object placement) under the key, write `types()` as definitions, a `/snippet/` schema per entry of `snippets()`, and completion lists per `Reference` from the server registries and the pack's biome, region and diff --git a/DESIGN.md b/DESIGN.md index 3d921f33a..03239fd67 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -47,7 +47,7 @@ name, version and optional packages; there is no separate descriptor. A pack kee The host loads a pack with `LoadedPack.load(packRoot, host)`. `ModuleHost` is the host's fixed configuration, built once and the same for every pack: built-in modules, exposed host packages, -host type packages and reserved folders. Each of its methods adds to what earlier calls +the JSON fields the host uses itself, host type packages and reserved folders. Each of its methods adds to what earlier calls configured, and all names are checked when it is built. `LoadedPack` runs `PackModules.load` (below), then `LoadedModules.load` on the built-ins followed by the pack's modules. If the second step fails it closes the first before rethrowing, so a failed load leaves no class loader or jar copy behind. @@ -568,13 +568,29 @@ ids. Two modules with one id never get that far: the load fails naming both ("Du ### JSON keys -Packs write a feature's settings under its feature id at each of its targets, always as the settings -object: `"example:moss": {...}`. A single option is not written bare (`"example:moss": 0.5` and a bare list -are not accepted); the object is the one shape, so a class gaining a second option never changes how packs -read. A `@Snippet` class may be written as a `"snippet/..."` string instead of the object. The id is unique, -namespaced and owned by one module, so two modules can never claim the same key, and a key can never be one of -the host's own fields: those have no `:`. There are no short aliases; pack files written for an older -shape are converted by the host's migration tooling, never by the loader. +Packs write a feature's settings under the short key its `@Feature` declares (`key`, required), at each of +its targets: `"moss": {...}`. The feature id (`example:moss`) is the identity everywhere else (stage graph, logs, +lookups by class) and is never a JSON key. A key is a plain field name, not blank and without `:`. + +*Why a declared key and not the id.* Pack authors write these keys by hand, and a biome already says `deposits`, +`decorators`; `"iris:deposit": {"generators": [...]}` would make every existing pack unreadable and every file longer. +The id carried an implicit uniqueness guarantee (module ids are unique); a declared key has to be checked instead. + +*Uniqueness.* A key is unique per target (dimension, region, biome, object placement), across all loaded modules and +the host's own JSON fields of that target. The host passes its fields with `ModuleHost.reservingFields` (the same +fields it reads itself: a module may not take `name` or `generators` for a biome). `ModuleRegistry` claims `(target, +key)` for every feature it catalogs, settings and object generators alike, including types only a stage names, and a +clash fails the registration, so the pack load, with one message naming the key, the target and both claimants (feature +id and the module's jar, or `Iris` for a host field): `biome key "deposits" is claimed by iris:deposit (host classpath) +and acme:ores (modules/acme-ores.jar)`. Claimants are listed host field first, then built-in features, then pack +features, then by feature id, so the message does not depend on which module registered first. + +*One shape.* The JSON under a key is the object of the class's options, unless `@Feature(root = "