Registration lifecycle and publication
Plugin authors use module.TypedContent(ctx) only during Load.
On this page
Overview
module discovery / dependency ordering
→ Load: module-owned typed staging
→ Load success: seal batch; Load failure: discard batch
→ resolve defaults/resources/cross-references
→ lowering all enabled protocols
→ prepare host-owned registries, palettes and client projections
→ atomic publish / freeze
→ Start
→ listener / players
Plugin authors use module.TypedContent(ctx) only during Load. On return from Load, the scope closes permanently. A retained registrar returns ErrRegistrationClosed in Start, a task callback or a later invocation. A thread-safe scope does not permit background registration that expects to continue after Load returns.
Load transaction
Each module load has its own owner with name/version/generation. Register copies the declaration, validates its shape and reserves IDs in that staging scope. A block and its automatic item reserve both IDs only after all checks for that call succeed.
Scope synchronization does not permit concurrent writes through caller-owned pointers/slices while Register/Clone is copying the declaration. Modify the declaration before the call or after it completes; finish registration goroutines before returning from Load.
If Load returns an error, its entire typed batch is discarded, including earlier successful registrations. Do not log and ignore errors for required content. Successful Load means sealed declarations; missing assets or cross-module collisions can still reject startup.
Forward references are resolved after collecting all successful batches. Normalized items and blocks are sorted by semantic ID; allocation does not depend on map iteration order. Duplicate IDs fail with owner context instead of updating or overwriting content. Block and item namespaces are distinct, but an automatic block item occupies the item namespace.
Commit and freeze
The host prepares independent snapshots without live registration. Before commit, it rechecks registry revisions, ID collisions and the scoped ProtocolNext source. Failures in defaults, resources, lowering or preparation do not publish a partial batch. One atomic pointer publishes the typed gameplay/registry views, palettes and client definitions together; no fallible work follows the store.
Successful typed publication closes registry mutation. Do not remove an item to register it again, change runtime IDs or add a block in Start. Existing APIs report refusal with an error or false according to their signatures; ordinary plugins must not bypass freeze through a concrete server.
Client session pinning retains its selected protocol projection, IDs and resource stack for that session. Changing a plugin-owned variable or staged declaration does not modify pinned content.
Start, Stop and failure
Start(context.Context) starts module behavior after publication and before admitting clients. If it returns an error, startup must not open the server to players; the lifecycle caller closes the host. The published snapshot does not become a new mutable staging scope.
Stop(context.Context) stops module behavior and releases owned services. It does not promise hot unloading typed definitions: placed blocks, inventory and packet references require stable serialization until server shutdown. This API does not implement runtime replacement/hot reload or persisted-world migration when a plugin is removed.
A typed transaction covers typed content, not arbitrary side effects in Load. A plugin's external writes or legacy registrar calls do not inherit typed rollback guarantees. Legacy registration is eager and uses existing cleanup; see migration.
Logging
Use ctx.Logger(). The module adapter adds module, version and load_generation; do not import log/slog solely for global slog.Info or repeat those fields manually. During Load, log “definitions staged”, not “content published”: final validation and commit have not completed.
Lifecycle checks: typed_content_test.go, content_publication_test.go, published_content_test.go. Unit/wire checks do not replace live client verification.
Documentation source
Snapshot from Pulce 4fc8a1bb. This page is generated from committed Markdown; code examples are preserved unchanged.