Enforce namespace ownership: reserved namespaces and module-prefixed stage ids

- LoadedModules.load takes the host's reserved namespaces (such as iris);
  a pack module whose id uses one fails, naming its jar and the namespace.
- A module defines only stages whose ids start with its own id and '/'.
  Module ids may no longer contain '/', so ids cannot nest and every
  stage id has exactly one possible owner.
- Object feature ids and mantle keys must use the registering module's
  namespace; ModuleRegistry.register(DiscoveredModule) scopes registration.
- A settings type named in when(...) needs a feature id in the namespace
  of some module naming it, so modules can still condition on another
  module's settings.
This commit is contained in:
piexel committed 2026-10-05 21:31:55 +02:00
1 parent 6263075ecd
commit 4cb718f706
13 files changed
+413 -129

No files matched your search

@@ -2,6 +2,7 @@ package com.volmit.host;
import com.volmit.FeatureAttachment;
import com.volmit.stage.Pipeline;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -17,10 +18,18 @@ public record LoadedModules(FeatureCatalog catalog, ResolvedGraph placement, Res
Objects.requireNonNull(chunk, "chunk");
}
/** Pass the built-in modules together with {@link PackModules#modules()} of the pack. */
/** Pass the built-in modules together with {@link PackModules#modules()} of the pack.
*
* @param reservedHostFields JSON fields the host itself uses, per attachment target
* @param reservedNamespaces namespaces only built-in modules may use, such as {@code iris}; a
* pack module whose id uses one fails the load
*/
public static LoadedModules load(
List<DiscoveredModule> modules,
Map<FeatureAttachment.Target, Set<String>> reservedHostFields) {
Map<FeatureAttachment.Target, Set<String>> reservedHostFields,
Collection<String> reservedNamespaces) {
var reserved = ReservedNamespaces.of(reservedNamespaces);
modules.forEach(reserved::requireAllowed);
var registry = new ModuleRegistry(reservedHostFields);
var stages = new StageGraphBuilder();
for (var discovered : modules) {
@@ -36,7 +45,7 @@ public record LoadedModules(FeatureCatalog catalog, ResolvedGraph placement, Res
private static void installModule(DiscoveredModule discovered, StageGraphBuilder stages, ModuleRegistry registry) {
try {
stages.install(discovered);
discovered.module().register(registry);
registry.register(discovered);
} catch (LinkageError error) {
throw new IllegalArgumentException("Module " + discovered.info().id() + " from "
+ discovered.origin() + " failed to link or initialize a class while installing: " + error