Pulcedocs

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

AreaActual contractDeferred / important boundary
DefinitionsTyped value structs + fluent methodsNot a mutable builder, options DSL, or Register(any)
IDsSeparate ItemID/BlockID, strict plugin namespace validationParse/UnmarshalText are not universal vanilla reference parsers yet
Display textOmitted label generates no item component; explicit literal supportedNo translation key/localization mode; block lowering does not create a separate block display-name component
DefaultsOmitted hardness differs from zero; normalized profile currently 1.0The number is not permanently fixed in the public definition contract
Stack/creativeStack 64 and hidden by default; explicit categoriesNew defaults are not automatically applied to old specs
Block itemOpt-in, same or overridden ID/icon/name/stack/categoryDefault-state placement only; no restrictions/multi-state placer
LootNo drop, self drop, one fixed outputNo multiple/conditional outputs, loot tables, or Fortune/Silk Touch
ToolsPreferred mining family, not a harvest requirementNo tier or mandatory correct tool
VisualsTerrain alias for all faces, logical custom geometryNo per-face Materials, render modes, states/permutations
ResourcesAuthoritative enabled-stack references and structural/closure validationNo PackID, bindings, RequirePack, or plugin-owned embedded pack API
RegistrationModule Load Scope, cloning, local reservations, SealNo runtime registration/hot reload
ValidationWhole graph, authoritative collisions, assets, explicit protocolsNot a complete client-side schema/render/Molang validator
AtomicityOne nonempty server publication store after fallible workLegacy side effects are outside typed rollback
FreezeBlock/item mutations closed after nonempty publicationEmpty typed startup does not freeze; not a freeze of all APIs
Version strategyNonempty content: 898, 1001, 2168, 2169, 2193; unsupported rejectedNo auto skip/latest/degradation/negotiated feature policy
RuntimeServer-owned projection, one pin per session, scoped codecs/IDsPalette pointer immutable by host contract, not an editable copy
BehaviorExisting legacy behavior API retainedNo 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.

SourceDifferenceCurrent interpretation
Proposal: audit/current flowRaw specs and eager registrars described as the only path; no freezeBaseline before typed implementation. Legacy remains, but typed Scope, Prepared, and startup store are implemented
Proposal: visuals/raw sectionsMaterials, advanced components, future states examplesExtension direction, not a compilable current API
Proposal: migration sectionPhase 1–3 described as upcoming workFoundations, staging/lowering, and startup publication now exist; major Context migration does not
Proposal: target Contextctx.Content().Items() / .Blocks(), ctx.Resources()Current public helpers are module.TypedContent(ctx) / module.Resources(ctx)
Proposal: acceptanceIcons/placement/effects on real clientsAcceptance plan; unit/wire tests below do not close the live gate
docs/ru/plugin-api/content-builders.mdDefineBlock, DefineItem, raw Component, and hooks presented as the general happy pathLegacy behavior/spec guide. Start new simple items/full blocks with typed overview
docs/en/v0.3/content.mdItemSpec described as the public content entry pointCompatible old registrar, not a new semantic-path tutorial
core/module/capabilities.go GoDocNative 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 GoDocSeparately verify legacy send gates/898 replay restrictionPinned 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.

PropertySource / test
IDs, reserved namespace, explicit empty label, stack bounds, finite/zero hardnesscore/content/definitions_test.go: TestSemanticIDs, TestSemanticDefaultsAndValidation
Definition cloning, WithItem links, conflicting loot, geometry/categoriesSame file: TestSemanticOwnershipAndBlockItem, TestSemanticConflictingLootModes, TestSemanticGeometryReference, TestSemanticCreativeCategoriesAndOwnership
Omitted/explicit hardness, defaultsinternal/content/normalize_test.go: TestNormalizeDefaultsAndHardness
Block item overrides/self drop, forward references/collisionsTestNormalizeBlockItemOverrides, TestNormalizeCollisionsReferencesAndResources, TestNormalizeBlockAndAssociatedItemCrossOwnerCollisions
Scope closure and atomic dual-ID reservationTestScopeReservationsSealAndOwnership, TestBlockItemReservationFailureIsAtomic
Native module success/failure staging, logger ownershipinternal/modulehost/typed_content_test.go: TestTypedContentLoadStagesAndCloses, TestTypedContentFailedLoadDiscardsAndCloses, TestTypedContentIndependentModulesAndLogger
Preparation failure does not publish; real catalog missing/ambiguous/equivalent assetsTestTypedContentPrepareFailureDoesNotPublish, TestTypedContentAuthoritativeCatalogPrepareIsolation
Bootstrap-owned enabled stack; legacy catalog compatibilitybootstrap/resource_catalog_test.go: TestBootstrapResourceCatalogUsesEnabledStack, TestBootstrapResourceCatalogFailureIsExplicitForConsumers, TestBootstrapLegacyLoadDoesNotRequireNewCatalog
Logical atlas/model references; malformed JSON/PNG/path/assetscore/resourcepack/catalog_test.go: TestCatalogLogicalReferences, TestCatalogMalformedStructure, TestCatalogInvalidReferencedPNG, TestCatalogPNGDimensionsBound
Duplicate aliases and effective asset/model overridesTestCatalogAmbiguityAndEquivalentAssets, TestCatalogCrossPackAssetAndArtifactIdentity, TestCatalogGeometryEffectiveOverride, TestCatalogGeometryFormatVersionAmbiguity
Equivalent geometry and exact numbersTestCatalogGeometryDuplicatesWithinModel, TestGeometryNumberCanonicalizationIsExact, TestCatalogGeometryDifferentDefinitionsConflict
Catalog captures bytes and resource archive validationTestCatalogSnapshotDoesNotFollowFileMutation, the content regression tests; real ZIP test opts in through an environment variable
Audited lowering and actual protocol serializersinternal/content/bedrock/lower_test.go: the content regression tests, TestProjectionUsesActualProtocolSerializers, TestUnsupportedProtocolAndFeature
Hidden/explicit creative category and inheritanceTestCreativeMenusAndOverridesAcrossProtocols; core/server/content_publication_test.go: TestContentPublicationExplicitCreative
Seven injected failures and stale legacy revisionsTestContentPublicationFailureLeavesEveryViewUnchanged, TestContentPublicationRejectsStaleLegacyRevision
Atomic success, overlay/freeze, closed serverTestContentPublicationSuccessHiddenAndFrozen, TestContentPublicationClosedStartupRejected
Deterministic identities, server-owner isolation/closeTestContentPublicationDeterministicServerIsolation; ProtocolNext bedrock/palette/item/scoped_test.go
Bootstrap publishes before return, failure cleanupbootstrap/typed_content_test.go: TestBootstrapTypedContentPublishesBeforeReturning, TestBootstrapTypedContentFailureClosesWithoutPublishing
Pinned wire 898/2193, registry/inventory IDs, hidden/foreign creative, frozen packsruntime/published_content_test.go: PublishedContent* tests
Unknown custom updates/chunks do not become airTestPublishedContentRejectsUnknownCustomBlocks
Scoped equipment error handling and vanilla NBT transformationscore/server/content_identity_scoped_test.go: TestScopedPeerEquipmentRejectsInsteadOfAir, TestPublishedVanillaStackPreservesSemanticTransforms
Unsupported published protocol and world actor preferred-version fallbackTestPublishedItemEntriesRejectUnsupportedProtocol, TestPublishedWorldItemUsesEnabledProtocol
/give, survival placement/consumption, preferred tool, timed breaking, self drop, save/evict/reload/rejoin, feedback IDscore/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.