Startup publication and pinned content
Typed content becomes authoritative through one startup publication after successful module loads, normalization, and per-protocol preparation.
On this page
Overview
Typed content becomes authoritative through one startup publication after successful module loads, normalization, and per-protocol preparation. This guarantee applies to the standard bootstrap.New path: listeners/players start after publication. A public module does not call PublishPlan, read concrete server registries, or assign client IDs.
See Typed content pipeline for the preceding phase and Content overview for registration. Checked limitations are recorded in the audit.
Three distinct results
| Result | Available after | Meaning |
|---|---|---|
ItemRef / BlockRef | Successful Register in Load | Semantic ID accepted by the module Scope; not yet published |
bedrock.Prepared | Successful Normalize + Prepare | Private semantic snapshot and detached projections of every enabled protocol; registries/IDs unchanged |
Server publishedContent | Successful PublishPlan.Commit | Common authoritative generation for gameplay metadata, item identities, palettes, and session source |
These results are not interchangeable. A module reference does not prove that a client has an icon; Prepared does not enable /give; atomic commit does not prove packet/pack delivery or client application.
Standard startup
bootstrap.New creates the server/module host and enabled-pack catalog, runs native module Load and existing plugin initialization. After legacy plugin registration, it calls Manager.PrepareTypedContent with the exact runtime configuration protocols, then Server.PrepareContentPublication and PublishPlan.Commit. A preparation/publication failure returns from bootstrap and initiates manager/server cleanup; no typed generation becomes visible.
Legacy content registered during initialization is therefore present in authoritative collision/reference checks. Typed blocks/items are not published individually through old Register methods. Start is not another registration window: the module Scope closes when Load returns.
For an empty typed snapshot, preparation creates a plan without next; commit succeeds without an atomic store. A startup with no typed declarations consequently acquires no typed generation, fixes no new palettes, and activates no new freeze guard. This is intentional compatibility for legacy deployments, rather than a global freeze on every server startup.
Preparing a complete server generation
A nonempty plan retains base block/item registry revisions and a snapshot of owner-local ProtocolNext custom specs. Legacy entries are retained: the complete projection combines vanilla, the server owner's legacy content, and typed content. Bootstrap owner 0 participates in owner-local specs too; other server owners are excluded.
For each enabled protocol, the plan:
- Builds typed gameplay definitions/placement/drop metadata separately from mutable base registries.
- Obtains vanilla item entries and builds a detached complete registry with
PrepareEntries, including legacy overrides. - Builds a combined palette from the canonical vanilla palette, existing legacy custom blocks, and typed default-state definitions.
- Checks runtime/network ID uniqueness in the palette.
- Produces rich StartGame block definitions containing components, menus, and block metadata.
- Produces explicit typed creative entries/groups; hidden definitions are not added.
- Retains a frozen enabled resource stack in the protocol projection.
Item allocation is deterministic: specs are sorted by semantic name, legacy override IDs are checked for collisions, and automatic allocation starts at 10000 + len(vanilla), skipping occupied IDs up to MaxInt16. Overflow returns an error. This is an internal algorithm, rather than a public promise of a specific ID.
The combined block palette uses the existing ProtocolNext client-order merger. In sequential palettes, RuntimeID and NetworkID equal the entry's sorted position; adding custom names can move vanilla IDs. In hashed palettes, existing entries retain their IDs, while custom entries receive NetworkHash(name, properties) in both RuntimeID and NetworkID; the loader also sets hashed runtime IDs from network IDs. The current custom path must not be described as “positional runtime ID plus hash network ID.” The guarantee is consistency of the whole projection, rather than preservation of each old vanilla number. Plugins must not persist those numbers in gameplay data. The world stores semantic names/properties; the palette projects them for a specific client.
Commit and observable rollback
Commit holds the publication mutex and lifecycle lock. It rejects repeated nonempty publication, a closed server, an established runDone, and existing runtime sessions. A guard chain then locks the block registry, item registry, and owner catalog in that order. It checks revisions, new-name collisions, and unchanged owner specs.
After all fallible checks, one s.publishedContent.Store(next) runs. There is no fallible work after the store within this commit closure. Registry providers and the runtime content source already read this pointer; publication does not perform multiple Register calls followed by undo operations.
Fault-injection tests use seven labels: gameplay, allocation, catalog, palette, projection, hooks, and commit. These are prepare/commit testing checkpoints, not seven implemented subsystems. In particular, hooks is reserved: the typed MVP declares no behavior callbacks or callback leases. The test does not prove rollback for future hooks that do not exist here.
Rollback means that injected failure or a stale source leaves typed definitions, gameplay views, owner catalog views, and generation in their pre-publication state. Existing legacy mutations already performed by other APIs are not undone. If a registry changes between prepare and commit, the plan is rejected; the mutation is preserved and startup must prepare again.
Freeze and ownership
After a nonempty commit, block/item registries retain base storage and read the typed overlay through publication providers. Definition and Definitions return merged views. Existing block/item Register operations are rejected by the freeze guard to preserve palette/catalog consistency after publication. The guard follows a server pointer rather than a permanent process-global flag.
Freeze does not close every capability: effects, entities, commands, events, and transport resource pack registries do not become one Content transaction. Legacy declarative owner lease APIs remain a separate system with their own lifecycle and are not equivalent to a typed Scope.
The process-global ProtocolNext compatibility catalog remains available for old callers. Typed publication does not add staged items to global CustomEntries; an owner provider exposes the complete server generation through EntriesForOwner. SpecsForOwner includes owner-local legacy registrations and the bootstrap owner. Generic EntriesForOwner retains a pre-publication fallback when its provider returns nil; the server wrapper separately rejects missing protocols after publication. That strict server guarantee must not be attributed to every global helper.
Closing a server cleans up its own legacy catalog registrations/provider without changing another server's published catalog/palette. Published IDs are fixed for a server startup, not reserved forever across servers/restarts. Two servers may contain the same semantic IDs with different content and their own projection IDs.
The current projection uses Generation=1. Module load_generation is an ownership diagnostic rather than a live-reload generation. Hot reload, replacement, and typed unpublication after startup are not implemented. Stopping a module does not reopen its typed registration window.
Session pinning and bootstrap
The server host installs Engine.SetContentSource before Engine.Run. Runtime negotiation obtains the negotiated protocol's projection after login preparation, before resource-pack exchange and gameplay bootstrap. bedrockWire.pinPublishedContent copies mutable data, validates its palette, announced blocks, and item name/runtime ID collisions, then pins the projection and a custom-aware inbound item codec once.
With pinning:
- ItemComponent/registry uses the exact complete pinned entries; raw registry replay containing process-global custom items is bypassed.
- StartGame receives rich pinned blocks; legacy environment send gates and captured StartGame replay do not replace published typed definitions.
- StartGame does not rebuild the combined palette or replace the pinned palette pointer.
- Inventory, equipment, and item actors receive session-specific IDs/data while vanilla metadata/NBT transformation is retained.
- ChunkView, SubChunk, and block updates use the pinned combined palette. Unknown custom names/states produce errors before legacy fallback.
- Creative filters foreign custom names and all typed entries out of the fallback catalog, then adds explicit visible typed entries once. Existing owner-local legacy entries remain.
- Creative network IDs/group offsets are allocated against the actual resulting catalog; server inbound lookup reads
CreativeForSessionrather than guessing order from a second global build.
ContentForSession and CreativeForSession return owned data copies. The palette pointer is immutable by host contract; ContentPaletteForSession exposes it for ID lookup rather than as an editable plugin registry. Published data structs belong to the runtime host API, not the semantic module surface.
The creative catalog is retained after successful encoding. This is the catalog prepared for sending; the accessor does not confirm transport delivery or client application. Live acceptance still checks actual presentation.
Resource stack and delivery
Pinning captures the Packs slice, ContentKeys map, and stack options. ResourcePacksInfo, ResourcePackStack, DataInfo, and chunks use this same stack. A pinned nil stack means no packs, rather than falling back to changed live configuration.
Download requests are restricted to the frozen enabled packs and requested version. The transport Registry remains the original shared provider rather than a copy of every ZIP: current Pack metadata must match the pinned metadata before chunk delivery, and Registry validates artifact integrity. A changed file produces an error rather than becoming a new frozen resource. The catalog validation snapshot itself does not follow filesystem mutations.
Pack order retains enabled-stack priority, highest first. Typed validation nevertheless rejects conflicting referenced aliases rather than silently choosing a winner. Frozen metadata does not make acceptance mandatory: ForceResources is copied from configuration and optional decline preserves existing behavior. Operators needing mandatory assets must configure the appropriate pack policy.
Gameplay and feedback
Gameplay readers use one published pointer for hardness, drops, placement links, and item registry identities. /give, survival placement, mining/drops, and world persistence operate on semantic IDs. World item actors may be created without an observing session: when their preferred version is unsupported, the host chooses a deterministic enabled published version for actor presentation, and runtime subsequently projects its identity per session. This is not an unsupported-protocol fallback for client packets.
Sound/particle lookup in block_sound.go first uses the pinned session palette. For a session without a wire pin, the existing bedrock_custom_blocks=true branch reads the server palette for that protocol; after publication, it comes from the frozen generation too. Other unpinned sessions retain legacy resolution. The feedback test checks runtime ID in sound extra data and destroy-particle data, rather than proving unique sounds or texture/model rendering on every client. Missing state mapping in the pinned path rejects feedback with a diagnostic; this strict guarantee does not apply to all standalone legacy lookup helpers.
Embedding host boundary
The startup guarantee described here is enforced by bootstrap.New and Server.Run lifecycle. Server.Engine() exposes lower-level runtime access for embedding hosts. Calling Engine.Run directly does not establish Server.runDone; PublishPlan.Commit checks server lifecycle and sessions, but not the separate engine-started flag. A custom embedding host is therefore not automatically protected against a late commit between starting Engine.Run and the first session.
This is a host-boundary limitation, not permission for runtime registration through the public typed API. Embedded hosts must finish publication before starting the engine and must not replace its source. Hardening that guard is a separate implementation issue; this documentation does not extend the guarantee to bypasses of standard bootstrap.
Documentation source
Snapshot from Pulce 4fc8a1bb. This page is generated from committed Markdown; code examples are preserved unchanged.