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

@@ -1,17 +1,26 @@
package com.volmit.resource;
import java.util.Objects;
import java.util.regex.Pattern;
/** Case-sensitive namespaced identity. Parsing never supplies an implicit namespace. */
public record ResourceId(String namespace, String path) implements Comparable<ResourceId> {
private static final Pattern NAMESPACE = Pattern.compile("[a-z0-9_.-]+");
private static final Pattern PATH = Pattern.compile("[a-z0-9_./-]+");
public ResourceId {
Objects.requireNonNull(namespace, "namespace");
Objects.requireNonNull(path, "path");
if (!namespace.matches("[a-z0-9_.-]+") || !path.matches("[a-z0-9_./-]+")) {
if (!isNamespace(namespace) || !PATH.matcher(path).matches()) {
throw new IllegalArgumentException("Invalid resource ID: " + namespace + ":" + path);
}
}
/** Whether {@code value} is a valid namespace on its own, such as {@code iris}. */
public static boolean isNamespace(String value) {
return NAMESPACE.matcher(value).matches();
}
public static ResourceId parse(String value) {
Objects.requireNonNull(value, "value");
int separator = value.indexOf(':');