Repository navigation
Description
Describe the desired outcome from the user's perspective
As a Zilla operator, I want a catalog to be able to supply a compiled transform for a resolved schema, so that behaviour derived from the schema registry can be installed without the engine or the models containing any of it.
Open scope question, not a staleness fix: does anything still need this? The composition pattern this issue was designed for — a registry-mode catalog resolving its own vendor rule set into a transform the model composes with — is achievable a different way with what's already shipped: an installed per-codec extension (AvroModelExtFactorySpi and peers, #1681–#1684) can reach a live CatalogHandler directly (via the model's own already-resolved catalog reference) and drive whatever it needs from there, rather than the catalog handing a value back through a new CatalogHandler method. No known current consumer needs a catalog-supplied ModelTransform via the mechanism below. Worth deciding whether to keep this open on the strength of the capability being generically useful on its own, or close it until a real need reappears.
Acceptance criteria
-
Add to
CatalogHandler:default ModelTransform supplyTransform(long traceId, long bindingId, int schemaId) { return ModelTransform.NONE; }
Return type is
ModelTransformdirectly — noClass kindtoken. The token's only purpose was avoiding a licensing dependency fromengine(Apache-licensed) onto the Aklivity-Community-Licensedcommon-avro/common-json/common-protobufmodules;ModelTransform(Add a pluggable per-field ModelTransform hook to the model pipeline (decode + encode) #2325→feat(engine): add pluggable per-field ModelTransform hook to the model pipeline #2326, merged) is engine-native, so that dependency never arises. A catalog implementation still resolves the schema's format internally to build the right transform — it already has the schema id and determines format from what it resolves; it never needed the caller to supply which kind to build. -
Catalog-supplied and model-owned transforms compose — they are not alternatives. A deployment can legitimately want a catalog purely for schema validation while using a model-owned transform for something else on the same schema — composition has to work per-field, not just per-deployment, since either seam may claim a disjoint subset of fields on the very same message.
-
Default returns
ModelTransform.NONE, unconditionally. The model's own composed transform (built from whatever extensions are installed against itsModelExtFactorySpi, per Declare AvroModelExtFactorySpi and wire provider-supplied pipeline stages in avro model #1681–Add bytes and string models and declare their ModelExtFactorySpi to wire provider-supplied pipeline stages #1684) runs regardless of what the catalog returns, andModelTransform.NONEcomposes for free (the same cheap-elision behavior already established forModelTransform.NONEelsewhere). There is only one state — nonull-vs-sentinel distinction to maintain. A fail-closed concern ("capability absent, reject at startup if something was configured expecting it") is each catalog implementation's own startup-validation responsibility, not something a generic caller infers from the return value. -
Composition order:
catalogTransform.andThen(modelOwnedTransform)on encode, reversed on decode — the standard last-applied-first-stripped ordering for any layered composition, the same shape every multi-stage transform chain in this design follows. For disjoint fields (the expected case) order doesn't matter at all, since each layer only touches what it claims. Order matters only when the same field is claimed by both, which composes as one more position in whatever chain-composition mechanism the model-owned transform already uses, not a new mechanism. -
Caching this composed transform by schema id depends on one required property: a schema id is immutable once assigned. Any catalog implementation this SPI supports must guarantee that resolving the same schema id always yields the same schema definition and any attached rule/metadata — never a mutated one in place — and that a rule change mints a new schema id rather than altering the existing one's registration. Given that, a catalog-supplied transform resolved once per schema id, and its composition with the model-owned transform, never needs re-resolving for the lifetime of that id.
-
model-avrobuilds its own concreteModelTransformimplementation —AvroModelTransform— distinct from theAvroModelDecoderTransform/AvroModelEncoderTransformadapters that bridgeAvroEvent↔ModelEvent; this is model-avro's own internal composition root, and is not itself tracked by any GitHub issue in this epic — Declare AvroModelExtFactorySpi and wire provider-supplied pipeline stages in avro model #1681–Add bytes and string models and declare their ModelExtFactorySpi to wire provider-supplied pipeline stages #1684 declare the generic extension-point SPI (AvroModelExtFactorySpiand its siblings) that installed providers plug into, which is a distinct piece of scope from the model's own baseModelTransformimplementation that those providers plug into.model-json/model-protobufget the analogousJsonModelTransform/ProtobufModelTransform. -
Default returns
ModelTransform.NONE, so existing catalog implementations are unaffected — same guarantee the old default-nullgave, restated for the new type. -
Javadoc stays protocol-neutral per
runtime/engine/AGENTS.md— no mention of encryption or Kafka -
Unit coverage: the default returning
ModelTransform.NONE; a test catalog whose supplied transform composes correctly with a model-supplied transform on the same schema, covering both the disjoint-field case and the same-field chain case; encode/decode ordering (catalog transform outermost on encode, innermost on decode)
Additional context
This replaces the March 2026 draft's Appendix A — FieldEncryption, TaggedFieldConsumer, DekConsumer, NO_DEK_VERSION, NO_FIELD_ENCRYPTION, and newFieldEncryption(...) are all withdrawn.
Rationale: an earlier draft had two separate cipher implementations, one model-side and one catalog-side. This design has one, model-side, with catalogs and vaults only parameterizing it. A provider returns a compiled transform which the model composes through the existing stream.transform(t).into(sink) — inheriting Status, resume(...), reset(), SUSPENDED/STARVED, and identity() for free.
Scope note: this issue was previously four separable engine changes and has been split so each is independently reviewable and landable:
- this issue —
CatalogHandler.supplyTransformand its composition with model-owned transforms - engine: add per-message authorization to ModelPipeline.transform #2310 —
long authorizationonModelPipeline.transform(...)(shipped) - Declare AvroModelExtFactorySpi and wire provider-supplied pipeline stages in avro model #1681 (avro), Declare JsonModelExtFactorySpi and wire provider-supplied pipeline stages in json model #1682 (json), Declare ProtobufModelExtFactorySpi and wire provider-supplied pipeline stages in protobuf model #1683 (protobuf), Add bytes and string models and declare their ModelExtFactorySpi to wire provider-supplied pipeline stages #1684 (bytes/string) — the generic per-codec
ModelExtFactorySpideclarations that let an installed provider compose its own stage(s) into each model's pipeline (all shipped). These are a distinct piece of scope from the model's own internalModelTransformimplementation described a few bullets above — buildingAvroModelTransformitself is not tracked by any of these four issues, only the extension point it exposes to installed providers is.
Alternative considered: per-codec capability interfaces declared in the codec libraries with instanceof on the handler. More conventional typing, but it makes catalog capabilities implicit at the call site.
Activity
[-]Extend CatalogHandler SPI with FieldEncryption strategy[/-][+]Extend engine SPI for provider-supplied field transforms[/+][-]Extend engine SPI for provider-supplied field transforms[/-][+]engine: extend CatalogHandler with provider-supplied field transforms[/+]jfallows commentedon Aug 4, 2026
Correcting the
Framingdescription. The body above describesTINKframing as "Confluent magic byte + key-version prefix." That is wrong, verified againstconfluentinc/schema-registryand by executing Tink 1.16 directly.There is no Tink output prefix.
Cryptorobtains its AEAD primitive viaRegistry.getPrimitive(dekTemplate.getTypeUrl(), dek, Aead.class)— a bare key-manager primitive rather than aKeysetHandle— so Tink's output-prefix variant declared on the key template is never applied. Confirmed empirically: the template reportsoutputPrefixType=TINK, but the primitive iscom.google.crypto.tink.subtle.AesGcmJce, and an 11-byte plaintext yields exactly 39 bytes = 12 + 11 + 16, with a random first byte rather than0x01.Actual layouts:
MAGIC_BYTE = 0x00followed by a big-endian int32 DEK version, and it is present only whenencrypt.dek.expiry.days > 0— i.e. only when DEK rotation is enabled. Otherwise the two framings are byte-identical.stringfield the prefix sits inside the base64 encoding, not outside it.This actually validates keeping two framings, for a better reason than the one recorded. The version prefix exists because registry mode resolves the DEK from the DEK Registry by
(kekName, subject, version, dekFormat)and so must carry the version in the payload. Embedded mode does not need it, becausezilla:edekcarries the EDEK per message. So the distinction is "does the payload need to identify which DEK", not "which vendor's format".One more variant to be aware of, relevant to
strategy: encodedverification.AES256_SIVis a supported Confluent DEK format with a different layout —SIV(16) | ciphertext, length = plaintext + 16, also unprefixed. A verifier that assumes GCM framing would misjudge a SIV-encrypted field. Out of scope for v1 encryption, since we specify AES128_GCM and AES256_GCM, but the verification path in aklivity/zilla-plus#1162 should either handle it or reject it explicitly rather than silently misread it.Not fully verified: no Confluent test asserts an exact byte layout — their
CryptorTestonly round-trips — so this rests on source reading plus independent execution. Only the Java and Go clients were inspected.Generated by Claude Code