Repository navigation
Description
Describe the desired outcome from the user's perspective
As a Zilla operator, I want opaque bytes and plain string models — for payloads with no schema or catalog — that let an installed module contribute its own pipeline stage, for whatever purpose that module defines, the same way the avro/json/protobuf models do (#1681–#1683).
Acceptance criteria
1. The bytes model — does not exist yet and must be created
model-core currently registers only BooleanModelFactorySpi, DoubleModelFactorySpi, FloatModelFactorySpi, Int32ModelFactorySpi, Int64ModelFactorySpi, and StringModelFactorySpi — StringModelFactorySpi already exists as a model type, but with no extension point (§2 adds one). Add a bytes model, registered via ModelFactorySpi, treating the value as opaque with no field traversal, no schema, and no catalog. Config schema patch, config class, and config adapter alongside — the config surface is minimal, since there's no schema/catalog reference to carry (unlike avro/json/protobuf's catalog: block).
Why bytes and string together, and not the other four model-core types. boolean/double/float/int32/int64 have no concrete stated need for a whole-value extension point, and some are dubious even hypothetically — a boolean's two-value domain defeats most of the point of encrypting it. bytes was the original, concrete driver (schema-less full-payload protection). string is the second real case: freeform text payloads are common in practice, and a disclosure action set can legally include actions for string that don't apply to bytes (masking a character pattern, for instance, presupposes readable text) — so string isn't just "bytes with a different name," it has a genuinely richer disclosure story once it's included. The other four types remain out of scope absent their own concrete need, not ruled out structurally.
2. The SPI — same pattern as #1681, minus the schema parameter, once per type
bytes and string both have no schema and no catalog by definition, so there is nothing to key a per-schema-id cache by, unlike #1681 §1's supplyHandler(AvroSchema schema, AvroModelConfig config). Resolution here is startup-only — once per model config, not once per resolved schema id. Two independent SPIs, one per type, mirroring how BooleanModelFactorySpi/Int32ModelFactorySpi/etc. are each their own independent ModelFactorySpi despite sharing a module:
// io.aklivity.zilla.runtime.model.core.ext, model-core's first exported package for this
public interface BytesModelExtFactorySpi extends FactorySpi
{
BytesModelExt create(Configuration config);
}
public interface BytesModelExt
{
String name();
BytesModelExtContext supply(EngineContext context);
}
public interface BytesModelExtContext
{
// called once per model config, at startup — no schema to resolve per
BytesModelExtHandler supplyHandler(BytesModelConfig config);
}
public interface BytesModelExtHandler
{
BytesTransformable transform(BytesTransformable stream);
}
// StringModelExtFactorySpi / StringModelExt / StringModelExtContext / StringModelExtHandler
// mirror the four Bytes* interfaces above exactly, substituting String throughout —
// StringModelExtContext#supplyHandler(StringModelConfig config), StringTransformable, etc.BytesTransformable/StringTransformable are new, minimal interfaces in model-core (transform(BytesTransform/StringTransform): BytesTransformable/StringTransformable), the same shape as common-avro's AvroTransformable (#1681 §1) — except they live in model-core itself rather than a common-* codec library, since there is no common-bytes/common-string codec library for either to sit alongside; neither model has a wire format to decode in the first place.
Registered via META-INF/services/io.aklivity.zilla.runtime.model.core.ext.BytesModelExtFactorySpi and ...StringModelExtFactorySpi respectively — two independent service files, two independent discovery sets. Any number of implementations may be installed at once per type; every one discovered contributes independently, via Factory.instantiate(ServiceLoader.load(...)) — same discovery mechanism as #1681 §1.
3. Composition and caching
BytesModelFactorySpi.create(Configuration)/StringModelFactorySpi.create(Configuration) each discover every installed extension SPI of their own type and call supplyHandler(config) once, at model construction, not per message and not per schema id (there being no schema id). The resulting composed handler is reused for every message that model processes, for the lifetime of that model instance. A deployment with zero installed extensions of a given type pays nothing for that type — the fold is a no-op and the model behaves exactly as if this SPI didn't exist. The two types' extensions are entirely independent — an installed BytesModelExtFactorySpi implementation has no effect on string, and vice versa.
4. Scope
Both SPIs define only the generic composition mechanism above, exactly per #1681 §3. Any installed extension's own purpose — encryption, disclosure, or anything else — and any config surface it needs, is entirely its own design, attached via the Config/ConfigBuilder extension mechanism (ModelExtInfo/ConfigExtAdapter, delivered per #2360) rather than any oss-declared field on BytesModelConfig/StringModelConfig. This issue declares no opinion on what any installed extension is for — in particular, it carries no business-specific vocabulary for what an installed extension does with these hooks, and no dependency on any particular downstream implementation. All of that has moved elsewhere — mirroring exactly how #1681–#1683 carry no encryption:/disclosure: vocabulary for avro/json/protobuf either.
5. Coverage
Unit coverage in model-core, for each of bytes and string independently: SPI discovery via a Configuration-supplied test factory SPI, supplyHandler invoked once per model construction (not per message), a stage installed ahead of whatever that model's own (trivial, passthrough) processing is, multiple registered extensions of one type composing in discovery order, a zero-extension deployment producing unmodified passthrough behavior, and an installed bytes extension having zero effect on a string model instance in the same engine (and vice versa).
Additional context
Sequenced after #1680 in this epic's plan, and after #1681 shipping first as the pattern to mirror (done); this SPI's own discovery mechanism (Factory, Configuration, EngineContext) is pre-existing engine plumbing that predates #1680, not something #1680 itself introduces — there is no hard technical dependency between them.
Activity
[-]Implement full payload encryption in bytes model[/-][+]Add bytes model with BytesTransformFactorySpi for full payload encryption[/+]jfallows commentedon Aug 4, 2026
Closing out the open question in the body above, and one wire-format simplification that lands here.
Chunk descriptors reach the binding via
ModelVisitor.onBlock(int offset, int length)— a default method added in #1680. Not a separate collaborator and not an accessor onModelPipeline:supplyEncoder/supplyDecoder, no impact on existing callers, andModelVisitor.NONEkeeps workingCOMPLETE" caveatSo option 2 from the body is chosen, minus the
fieldIdparameter.zilla:efieldsis dropped, soonBlockcarries no field id. A field id is only interpretable with the schema that defines it, so the header was either redundant — a consumer holding the schema derives the mapping by traversal — or useless to a consumer without it. Neither the gateway nor the client deserializer consumed it. That removes the sentinel question this issue raised:bytesnow callsonBlockon exactly the same terms as the codec models, one call per chunk, rather than being a special case that skips it.Consequences for the acceptance criteria above:
zilla:efieldsis not written for this model is now trivially true of every model, and can be dropped as abytes-specific noteBytesTransformreports each chunk throughonBlock, with message-relative offsets that survive anOVERFLOWresumeEverything else stands: startup-only resolution with no catalog consulted,
BytesTransform.IDENTITYinmodel-core, in-band chunk framing,otherwise: redactrejected, and produce-streams/consume-verifies-per-chunk.Generated by Claude Code
jfallows commentedon Aug 4, 2026
Correction to my previous comment: it says chunks use "in-band chunk framing". That contradicts keeping
zilla:edata, and the two are redundant — ifedatacarries[offset|length]per chunk, an in-payload length prefix describes the same thing a second time.Chunks are described by
zilla:edataonly. No in-payload length prefixes:[IV][ct][tag][IV][ct][tag]…, one region per chunk, with positions inzilla:edatabytesmodel and the codec modelsIn-band prefixes would only be justified if
zilla:edatawere dropped, which it isn't (#1680 — it serves the schema-less client deserializer in aklivity/zilla-plus#822).Everything else in that comment stands:
onBlock(offset, length)as the descriptor channel, one call per chunk, no field id, andbytesreporting on the same terms as the codec models.Generated by Claude Code
[-]Add bytes model with BytesTransformFactorySpi for full payload encryption[/-][+]Add bytes model with BytesFieldTransformFactorySpi for full payload encryption[/+][-]Add bytes model with BytesFieldTransformFactorySpi for full payload encryption[/-][+]Add bytes model and declare BytesModelExtFactorySpi to wire provider-supplied pipeline stages[/+][-]Add bytes model and declare BytesModelExtFactorySpi to wire provider-supplied pipeline stages[/-][+]Add bytes and string models and declare their ModelExtFactorySpi to wire provider-supplied pipeline stages[/+]