Repository navigation
feat(model-core): add bytes/string models and ModelExtFactorySpi composition - #2382
Merged
jfallows merged 4 commits intoAug 16, 2026
Merged
Conversation
Adds a new opaque `bytes` model to model-core, treating the value as a raw byte sequence with no field traversal, no schema, and no catalog. Adds independent `BytesModelExtFactorySpi`/`StringModelExtFactorySpi` SPIs (mirroring model-avro's `AvroModelExtFactorySpi`) so an installed module can contribute its own whole-value pipeline stage to either model. Since bytes and string have no schema, resolution happens once per model config at handler construction rather than once per resolved schema. `BytesTransformable`/`StringTransformable` and their `*Transform` companions live directly in model-core (no `common-bytes`/`common-string` codec module exists, since neither model decodes a wire format). Composition folds installed extensions ahead of the model's own passthrough validate-and-copy processing; a zero-extension deployment reuses the existing CoreModelHandler/ CoreModelPipeline unchanged. A new CoreExtModelHandler/CoreExtModelPipeline handles the ext-composed case, buffering the whole value across fragments (needed since a transform requires the complete value, unlike the existing per-fragment identity copy) and reporting installed extensions' combined padding contribution. Extensions apply on decode only; encode (the write path into the broker) always delegates to a plain CoreModelHandler so the source of truth is never altered on produce.
BytesTransform/StringTransform each carried their own padding(), duplicating BytesModelExtHandler/StringModelExtHandler's own padding() without either ever being summed together, leaving the handler-level method dead. Mirrors model-avro's AvroModelExtHandler.padding(schema): a single declaration point per installed extension, summed once at handler construction.
Picks up #2381, which lets the type: test binding drive a configured value model's decoder on the reply direction, not just the encoder on initial -- needed so model-core-ext's disclosure IT can exercise the actual decode-time transform through a live engine instead of only proving encode is a no-op.
…l IT CoreExtModelPipelineTest exercised the extension-composition mechanism (apply, fragment accumulation, OVERFLOW/drain, reject-on-omit) only by calling ModelPipeline.transform(...) directly with hand-sized buffers -- never through a live engine's frame dispatch and buffer lifecycle, so a passing unit test could still coexist with the mechanism being broken end-to-end. Add a test-only BytesModelExtFactorySpi (registered under src/test only, so it never ships in the production jar) that uppercases a value and signals OMIT for a single 0x00 byte -- generic and business-agnostic, exercising only the composition mechanism itself, not any particular installed extension's behavior. Wire it into three new CoreModelIT scenarios: a small round trip (apply), a ~100KB round trip (forces the pipeline's real OVERFLOW/drain-across-calls path, since the engine's 32KB default buffer.slot.capacity -- raised here to 64KB, still smaller than the value -- would otherwise abort the stream), and a single-byte sentinel (reject-on-omit). NetworkIT/ApplicationIT gain the matching peer-to-peer self-consistency checks. Remove the two CoreExtModelPipelineTest methods this now covers more faithfully (reject-on-omit, fragment accumulation before OVERFLOW/drain); keep the multi-extension padding-summing test, which has no realistic wire-level equivalent. Drop BytesModelFactoryTest.shouldDiscoverNoExtensionsByDefault, whose "zero installed extensions" premise no longer holds now that a test-only extension is genuinely registered for the module's own ITs -- shouldCreateReader already covers the same behavior directly via an explicit empty list, bypassing ServiceLoader discovery entirely.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
bytesandstringvalue models tomodel-core, and aModelExtFactorySpicomposition mechanism (BytesModelExtFactorySpi/StringModelExtFactorySpi) that lets independently-installed extensions transform a model's value on the decode path — analogous to the existingAvroModelExtmechanism, generalized to the core bytes/string models.Key additions:
BytesModelConfig/StringModelConfigand their factories inmodel-coreBytesModelExtFactorySpi/StringModelExtFactorySpiSPI:ModelExtContext→ModelExtHandler→Transformable/Transform, discovered viaServiceLoaderand composed unconditionally (every installed extension always applies)CoreExtModelPipeline: buffers a value acrossFLAGS_INIT/FLAGS_FINfragments, folds it through installed transforms, and drainsOVERFLOWoutput across multiple decode calls when a transform's output exceeds the available bufferBytesModelExtFactorySpi(registered undersrc/testonly, never shipped in the production jar) proves the composition mechanism end-to-end through a live engine (CoreModelIT): apply-on-reply, fragment accumulation,OVERFLOW/drain across multiple frames, and reject-on-omit -- independent of any specific extension's own testsFixes # (issue)
Test plan
./mvnw install -pl runtime/model-core,runtime/model-core.conf,specs/model-core.spec -am— checkstyle, license headers, unit tests, JaCoCo, and all k3po ITs (including the newclient.received.bytes.ext.*scenarios) passGenerated by Claude Code