Content API: implementation, proposal, and testable boundaries
This audit reflects Pulce c39fb383 and ProtocolNext 401658e.
On this page
Overview
This audit reflects Pulce c39fb383 and ProtocolNext 401658e. It reviews existing code and tests rather than proposing a new design. The practical API is described in the overview, semantics in typed content pipeline, and commit/runtime behavior in content publication.
The historical docs/architecture/content-api-proposal.md remains design rationale, not an inventory of available methods. Future ideas are separated from implemented contracts below. These differences are recorded without changing architecture, protocol format, or source code.
Improvements over the original API
A module can declare an item and a block without a ZIP parser, JSON maps, fs.Stat, a hardcoded manifest UUID, palette lookup, concrete *server.Server, or an external Verify. Typed definitions retain semantic intent; the resource service and host validation check assets; lowering generates Bedrock components; startup publication connects gameplay with runtime IDs.
The capability helpers are additive: module.TypedContent(ctx) and module.Resources(ctx) discover optional host interfaces and reject unsupported/nil hosts. The required module.Context and Descriptor have not been rewritten. ctx.Content() still returns the legacy registrar rather than typed Service; public examples must not present the future major-version form as available today.
Implemented and deferred
| Area | Actual contract | Deferred / important boundary |
|---|---|---|
| Definitions | Typed value structs + fluent methods | Not a mutable builder, options DSL, or Register(any) |
| IDs | Separate ItemID/BlockID, strict plugin namespace validation | Parse/UnmarshalText are not universal vanilla reference parsers yet |
| Display text | Omitted label generates no item component; explicit literal supported | No translation key/localization mode; block lowering does not create a separate block display-name component |
| Defaults | Omitted hardness differs from zero; normalized profile currently 1.0 | The number is not permanently fixed in the public definition contract |
| Stack/creative | Stack 64 and hidden by default; explicit categories | New defaults are not automatically applied to old specs |
| Block item | Opt-in, same or overridden ID/icon/name/stack/category | Default-state placement only; no restrictions/multi-state placer |
| Loot | No drop, self drop, one fixed output | No multiple/conditional outputs, loot tables, or Fortune/Silk Touch |
| Tools | Preferred mining family, not a harvest requirement | No tier or mandatory correct tool |
| Visuals | Terrain alias for all faces, logical custom geometry | No per-face Materials, render modes, states/permutations |
| Resources | Authoritative enabled-stack references and structural/closure validation | No PackID, bindings, RequirePack, or plugin-owned embedded pack API |
| Registration | Module Load Scope, cloning, local reservations, Seal | No runtime registration/hot reload |
| Validation | Whole graph, authoritative collisions, assets, explicit protocols | Not a complete client-side schema/render/Molang validator |
| Atomicity | One nonempty server publication store after fallible work | Legacy side effects are outside typed rollback |
| Freeze | Block/item mutations closed after nonempty publication | Empty typed startup does not freeze; not a freeze of all APIs |
| Version strategy | Nonempty content: 898, 1001, 2168, 2169, 2193; unsupported rejected | No auto skip/latest/degradation/negotiated feature policy |
| Runtime | Server-owned projection, one pin per session, scoped codecs/IDs | Palette pointer immutable by host contract, not an editable copy |
| Behavior | Existing legacy behavior API retained | No typed hooks/leases/raw escape hatch |
Older descriptions that are no longer current instructions
The following entries record outdated wording found before this documentation pass. Legacy pages are now labelled and the listed GoDoc comments have been corrected; behavior is unchanged.
| Source | Difference | Current interpretation |
|---|---|---|
| Proposal: audit/current flow | Raw specs and eager registrars described as the only path; no freeze | Baseline before typed implementation. Legacy remains, but typed Scope, Prepared, and startup store are implemented |
| Proposal: visuals/raw sections | Materials, advanced components, future states examples | Extension direction, not a compilable current API |
| Proposal: migration section | Phase 1–3 described as upcoming work | Foundations, staging/lowering, and startup publication now exist; major Context migration does not |
| Proposal: target Context | ctx.Content().Items() / .Blocks(), ctx.Resources() | Current public helpers are module.TypedContent(ctx) / module.Resources(ctx) |
| Proposal: acceptance | Icons/placement/effects on real clients | Acceptance plan; unit/wire tests below do not close the live gate |
docs/ru/plugin-api/content-builders.md | DefineBlock, DefineItem, raw Component, and hooks presented as the general happy path | Legacy behavior/spec guide. Start new simple items/full blocks with typed overview |
docs/en/v0.3/content.md | ItemSpec described as the public content entry point | Compatible old registrar, not a new semantic-path tutorial |
core/module/capabilities.go GoDoc | Native host “prepares private snapshots without publishing them” | Helper/host preparation is private; standard bootstrap additionally publishes a server generation |
internal/content/bedrock/lower.go Prepare GoDoc | Separately verify legacy send gates/898 replay restriction | Pinned runtime bypasses those gates/replay for a published projection; legacy behavior remains without a pin |
CreativeForSession GoDoc | “actual sent creative catalog” | Owned catalog after successful encoding, before confirmed transport delivery/client application |
The new guide does not declare legacy registration methods removed or already formally deprecated. Changing required Context.Content needs a future breaking major; the temporary helper should not be duplicated under module.Content.
Limitations that wording must not conceal
Load rollback covers typed content only. The Scope closes on successful/failed Load; defer closes it on panic too. Registered legacy specs, external mutations, and other capabilities are not rolled back by this mechanism. Acceptance before Seal does not guarantee eventual publication. Async registration after returning from Load is rejected, but a goroutine may register before Seal; thread identity is not checked.
An empty typed snapshot creates no generation. A nonempty commit produces Generation=1, freeze, and complete protocol projections. Empty-plan success is a no-op. The load ownership counter is a different generation, not a live-reload version. Repeated nonempty publication is rejected; live replacement is not implemented.
Failure labels are testing checkpoints. gameplay, allocation, catalog, palette, projection, hooks, and commit test absence of observable typed side effects. hooks does not prove callback/lease rollback: the typed MVP creates none. Registries remain base plus overlay rather than entirely replaced storage.
Strict protocol selection belongs to the server path. Published server wrappers reject protocols outside the snapshot. Generic ProtocolNext EntriesForOwner retains legacy fallback for a nil provider result. Global compatibility helpers do not automatically become server-scoped; typed runtime deliberately uses the pinned catalog instead.
Asset snapshots and artifact delivery are different guarantees. The catalog captures bytes; later file mutations do not change resolve results. Transport validates pinned metadata and artifact bytes rather than serving directly from Catalog. A frozen stack does not convert optional acceptance into required acceptance: ForceResources remains a host setting.
Catalog construction failure does not always fail legacy bootstrap. Bootstrap supplies a failed resource capability; asset resolution exposes the error. Native typed full blocks/items referencing assets fail preparation, while legacy code without resource lookups remains compatible. This is not mandatory exhaustive pack auditing for every legacy server.
Geometry duplicates require proven equivalence. The same identifier with an identical parsed geometry and format_version is allowed; no presumed client file winner is chosen. Different geometry within one pack is rejected even when no plugin references it. Cross-pack effective model overrides are also checked. Structural validation does not prove suitability for a client renderer.
Public Content lifecycle does not guard every embedding runtime call. Server.Engine() allows the host to call Engine.Run directly. Commit checks Server.runDone and existing sessions, but not the separate engine-started flag. Direct engine start before commit, without sessions, bypasses part of the standard startup guard. Standard bootstrap obeys the ordering; the guarantee cannot be extended to arbitrary custom hosts. This is a separate guard-hardening issue, not support for runtime registration.
Feedback is strict in the pinned path. Sounds/particles use a runtime ID from the same palette as the session. Legacy lookup without a wire pin retains older branches, including the server palette when the custom-content marker is set. Strict no-fallback behavior should not be promised for every standalone legacy helper. Server feedback tests and runtime encoding tests cover different portions of the path.
Evidence map and test matrix
This table describes existing test coverage rather than asserting that every full suite is always green. Paths are relative to repository root; test names identify reproducible focused checks.
| Property | Source / test |
|---|---|
| IDs, reserved namespace, explicit empty label, stack bounds, finite/zero hardness | core/content/definitions_test.go: TestSemanticIDs, TestSemanticDefaultsAndValidation |
| Definition cloning, WithItem links, conflicting loot, geometry/categories | Same file: TestSemanticOwnershipAndBlockItem, TestSemanticConflictingLootModes, TestSemanticGeometryReference, TestSemanticCreativeCategoriesAndOwnership |
| Omitted/explicit hardness, defaults | internal/content/normalize_test.go: TestNormalizeDefaultsAndHardness |
| Block item overrides/self drop, forward references/collisions | TestNormalizeBlockItemOverrides, TestNormalizeCollisionsReferencesAndResources, TestNormalizeBlockAndAssociatedItemCrossOwnerCollisions |
| Scope closure and atomic dual-ID reservation | TestScopeReservationsSealAndOwnership, TestBlockItemReservationFailureIsAtomic |
| Native module success/failure staging, logger ownership | internal/modulehost/typed_content_test.go: TestTypedContentLoadStagesAndCloses, TestTypedContentFailedLoadDiscardsAndCloses, TestTypedContentIndependentModulesAndLogger |
| Preparation failure does not publish; real catalog missing/ambiguous/equivalent assets | TestTypedContentPrepareFailureDoesNotPublish, TestTypedContentAuthoritativeCatalogPrepareIsolation |
| Bootstrap-owned enabled stack; legacy catalog compatibility | bootstrap/resource_catalog_test.go: TestBootstrapResourceCatalogUsesEnabledStack, TestBootstrapResourceCatalogFailureIsExplicitForConsumers, TestBootstrapLegacyLoadDoesNotRequireNewCatalog |
| Logical atlas/model references; malformed JSON/PNG/path/assets | core/resourcepack/catalog_test.go: TestCatalogLogicalReferences, TestCatalogMalformedStructure, TestCatalogInvalidReferencedPNG, TestCatalogPNGDimensionsBound |
| Duplicate aliases and effective asset/model overrides | TestCatalogAmbiguityAndEquivalentAssets, TestCatalogCrossPackAssetAndArtifactIdentity, TestCatalogGeometryEffectiveOverride, TestCatalogGeometryFormatVersionAmbiguity |
| Equivalent geometry and exact numbers | TestCatalogGeometryDuplicatesWithinModel, TestGeometryNumberCanonicalizationIsExact, TestCatalogGeometryDifferentDefinitionsConflict |
| Catalog captures bytes and resource archive validation | TestCatalogSnapshotDoesNotFollowFileMutation, the content regression tests; real ZIP test opts in through an environment variable |
| Audited lowering and actual protocol serializers | internal/content/bedrock/lower_test.go: the content regression tests, TestProjectionUsesActualProtocolSerializers, TestUnsupportedProtocolAndFeature |
| Hidden/explicit creative category and inheritance | TestCreativeMenusAndOverridesAcrossProtocols; core/server/content_publication_test.go: TestContentPublicationExplicitCreative |
| Seven injected failures and stale legacy revisions | TestContentPublicationFailureLeavesEveryViewUnchanged, TestContentPublicationRejectsStaleLegacyRevision |
| Atomic success, overlay/freeze, closed server | TestContentPublicationSuccessHiddenAndFrozen, TestContentPublicationClosedStartupRejected |
| Deterministic identities, server-owner isolation/close | TestContentPublicationDeterministicServerIsolation; ProtocolNext bedrock/palette/item/scoped_test.go |
| Bootstrap publishes before return, failure cleanup | bootstrap/typed_content_test.go: TestBootstrapTypedContentPublishesBeforeReturning, TestBootstrapTypedContentFailureClosesWithoutPublishing |
| Pinned wire 898/2193, registry/inventory IDs, hidden/foreign creative, frozen packs | runtime/published_content_test.go: PublishedContent* tests |
| Unknown custom updates/chunks do not become air | TestPublishedContentRejectsUnknownCustomBlocks |
| Scoped equipment error handling and vanilla NBT transformations | core/server/content_identity_scoped_test.go: TestScopedPeerEquipmentRejectsInsteadOfAir, TestPublishedVanillaStackPreservesSemanticTransforms |
| Unsupported published protocol and world actor preferred-version fallback | TestPublishedItemEntriesRejectUnsupportedProtocol, TestPublishedWorldItemUsesEnabledProtocol |
/give, survival placement/consumption, preferred tool, timed breaking, self drop, save/evict/reload/rejoin, feedback IDs | core/server/content_publication_gameplay_test.go: the content regression tests (898/2193) |
The gameplay regression exercises production command, inventory and mining paths with asset fixtures. Optional tests also load a real enabled resource stack. Session rejoining checks fixed IDs without proving a real network disconnect/login. Chunk reload is covered; a complete process restart with client caches is not separately proven. These checks do not verify client rendering.
Example focused commands from nucleus repository root:
go test ./core/content ./core/module ./core/resources ./core/resourcepack ./internal/content ./internal/content/bedrock ./internal/modulehost ./bootstrap -run 'Semantic|Catalog|Scope|Normalize|TypedContent|BootstrapTyped|Projection|ProjectionUsesActual|UnsupportedProtocol|CreativeMenus' -count=1
go test ./core/server -run 'ContentPublication|Scoped|PublishedVanilla|PublishedItemEntries|PublishedWorldItem' -count=1
go test ./runtime -run 'PublishedContent|CustomBlockItem|RawItemRegistry|ResourcePack|Bootstrap' -count=1
Resource-backed tests can load a real archive and enabled pack configuration. Their required environment settings and fixtures are documented in the test files. Generated fixtures run without external archives. Run focused tests and race checks separately; neither proves that the whole server or a live client has been tested.
Live acceptance remains a separate check
At least sequential 898 and hashed 2193 clients are needed on a real server with the pack enabled: download/apply, visible Token and block-item icons, survival placement/breaking/self drop, sounds/particles, vanilla blocks/palette, inventory/creative interactions, reconnection, and persisted chunk reload. Tests establish declarative, gameplay, and wire consistency; they do not certify client-visible texture/model presentation, resource acceptance, transport delivery, or cache behavior.
An advanced raw-component test for the new API is not possible yet: that typed escape hatch is not implemented. Tests of legacy components/behavior registrars are not acceptance tests for this future interface. This is a documented coverage gap rather than a reason to add an unavailable method to the guide.
Source boundaries to inspect
Public definitions: definitions.go, ids.go, capabilities.go, resources.go.
Host preparation: staging.go, normalize.go, lower.go, modulehost/typed_content.go, catalog.go.
Publication/runtime: bootstrap.go, content_publication.go, content_identity.go, published_content.go, block_sound.go. ProtocolNext's owner catalog is in the neighboring repository at bedrock/palette/item/scoped.go; its public compatibility helpers have a different fallback policy from the strict server wrapper.
Documentation source
Snapshot from Pulce 4fc8a1bb. This page is generated from committed Markdown; code examples are preserved unchanged.