Skip to content

feat(model-avro): add AvroModelExt SPI for provider-supplied pipeline stages - #2376

Merged
jfallows merged 5 commits into
developfrom
feature/avro-model-disclosure
Aug 14, 2026
Merged

jfallows merged 5 commits into
developfrom
feature/avro-model-disclosure

Conversation

@jfallows

Copy link
Copy Markdown
Contributor

Description

Adds a generic, business-agnostic extension point to model-avro so a provider-supplied stage can fold into the avro pipeline without the engine or model-avro knowing anything about what that stage does. This is the foundation a commercial disclosure (redact/omit) feature builds on downstream — the redact/omit logic itself lives entirely outside this repo; this PR only adds the extension mechanism.

Builds on the schema-annotation retention work from #2368.

  • AvroModelTransform now tracks a path prefix stack across START_RECORD/END_RECORD, so scalar fields nested inside a record (not just top-level fields) get a full path ("$.user.ssn") and are offered to the wired ModelTransform the same as a top-level field.
  • New AvroModelExt/AvroModelExtFactorySpi/AvroModelExtContext/AvroModelExtHandler SPI (package io.aklivity.zilla.runtime.model.avro.ext). AvroModelHandlerImpl.extend() folds every discovered extension's handler into the AvroStream pipeline, in discovery order, ahead of the model's own adapter stage.
  • Extensions are decode-only. supplyEncoder()'s pipeline never calls extend() — the encode path writes into the broker and must preserve the full, undisclosed value; a read-side concern like redaction only ever applies to supplyDecoder(), the path reading a value back out.
  • Config-side: ConfigAdapter.Extensible/ConfigBuilder.Extensible/ConfigExtAdapter/ModelExtInfo/ModelInfo.extensions() let a provider module register a config extension, discovered via ServiceLoader and filtered to the owning model's own type. Fixed EngineInfo.patches() to actually merge each model's extension schema patches into the aggregated schema (they were being discovered but silently dropped).
  • Extended the engine's TestBinding test double to forward the value model's real transformed output instead of discarding it and passing through the raw input — this is what makes it possible to write a real EngineRule+K3poRule integration test for a model extension, rather than only asserting accept/reject.
  • Also fixed two pre-existing, previously-undetectable fixture bugs uncovered by that TestBinding fix: model-avro.spec's client.sent.avro.json.valid scenario expected JSON text on the wire where the engine actually produces canonical Avro binary, and model-protobuf.spec's client.sent.protobuf.{binary,json}.valid scenarios were missing the leading message-index framing byte.

Test plan

  • ./mvnw test -pl runtime/model-avro — unit tests green, including the new extension-folding + decode-only-restriction coverage
  • ./mvnw verify -pl specs/model-avro.spec — full spec IT suite green (including the two corrected fixtures)
  • ./mvnw verify -pl specs/model-protobuf.spec — full spec IT suite green (including the two corrected fixtures)
  • A downstream commercial module (disclosure v1: redact/omit via this SPI) builds against this branch with a real EngineRule+K3poRule integration test proving redaction applies on fetch/decode and never on produce/encode

Fixes # (issue) — see #2302


🤖 Generated with Claude Code

https://claude.ai/code/session_01GKWELiLVoasTwsuvaXg2Y3


Generated by Claude Code

claude added 5 commits August 14, 2026 07:05
AvroModelTransform previously only withheld/mediated top-level (depth-1)
scalar fields; nested scalar fields (e.g. a record field's own string
field) forwarded verbatim regardless of the wired ModelTransform. Track a
path prefix stack across START_RECORD/END_RECORD so any scalar field
reachable only through records gets a full path ("$.user.ssn") and is
offered to the transform the same way a top-level field is. Fields nested
inside an array or map stay opaque (unsupported) since a single path can't
address a specific repeated entry.

Also marks disclose (added in the prior commit) as x-incubating in the
avro schema patch, matching the vault-filesystem precedent, since the
end-to-end design isn't settled yet.
… stages

Adds a way for an installed module to contribute its own AvroTransform
stage(s) into model-avro's pipeline construction, without model-avro
needing to know anything about what those stages do:

- common-avro: AvroTransformable (append-only, chainable stage builder)
  and AvroStream extends it, so a provider can append transforms to an
  in-progress stream without depending on AvroStream's fuller API.
- model-avro: new exported ext package (its first exports) with
  AvroModelExtFactorySpi (extends FactorySpi, so @Incubating gating and
  ServiceLoader discovery come for free via the existing Factory helper),
  AvroModelExt, AvroModelExtContext, AvroModelExtHandler — mirroring
  ModelFactorySpi/Model/ModelContext's own worker-scoped, EngineContext
  -threaded lifecycle exactly, narrowed to Avro. Any number of installed
  extensions compose, each folded into the stream ahead of the existing
  ModelTransform bridge, at the same point newPipeline already resolves
  and caches per schema id.

Verified end-to-end with a fixture ext supplied directly through the new
AvroModelHandlerImpl constructor parameter (no real provider module exists
yet) proving an installed extension's contribution takes effect
independent of whatever ModelTransform the caller supplies.
… take effect

EngineInfo.patches() never merged each model's registered ModelExtInfo schema
patches, so a config-extension schema patch contributed by a model extension
(e.g. zilla-plus's model-avro-ext) was silently discarded and any property it
declared failed validation. Fixed by including
models.values().flatMap(extensions).map(ModelExtInfo::schema) in the merged
patch list.

Separately, per-model allOf branches (avro.schema.patch.json) restricted their
own "then" schema with additionalProperties: false, which is evaluated purely
locally and can never see a sibling allOf branch's contributed properties —
this is what originally hid the bug above even once schema merging worked.
Moved the restriction to a single unevaluatedProperties: false on the shared
$defs/models/model schema (which sees annotations from every allOf branch,
including extension-contributed ones) and removed the avro branch's local
restriction. This requires 2019-09+ semantics, so engine.schema.json's
$schema is bumped from draft-07 to 2019-09; audited every schema patch
repo-wide for $ref used with validating (non-title) siblings, whose meaning
changes between drafts, and found none, so the bump is behavior-preserving
for existing configs.

Added AvroModelSchemaExtensionTest proving the generic mechanism (a sibling
schema patch contributing a new property is rejected without it and accepted
with it), and EngineInfoTest proving the patch-merging fix directly.
TestBindingFactory ran the configured value model purely as an accept/reject
gate: it always forwarded the original, untransformed payload downstream,
discarding whatever the model pipeline actually produced. This meant no
test using type: test could ever observe real model behavior beyond
validation — encoding, decoding, or extension-driven transformation was
never exercised, only whether the model accepted or rejected the input.

Forward the pipeline's actual output (the bytes written to modelBuffer)
instead. This surfaced two pre-existing, previously-undetectable fixture
bugs, now fixed:

- model-avro.spec's client.sent.avro.json.valid scenario asserted JSON text
  on the application side, but supplyEncoder() with view: json produces
  canonical Avro binary output (JSON in, Avro binary out) — the fixture
  never actually observed this, since the old TestBinding behavior masked
  it with a pure passthrough.
- model-protobuf.spec's client.sent.protobuf.binary.valid and
  client.sent.protobuf.json.valid scenarios were both missing the leading
  message-index framing byte in their application-side expectations,
  provably wrong per ProtobufModelEncoderPipelineTest's own WIRE constant.

model-json and model-core were unaffected (verified via their own IT
suites) since neither has this passthrough/re-encode distinction.
Model extensions (e.g. zilla-plus's disclosure ext) folded into both the
encoder and decoder streams. Encode is the write path into the broker, which
must keep the source of truth intact -- a read-side concern like disclosure
redaction belongs only on decode, the read path out of the broker.

No existing coverage exercised an extension on the encoder path, so this is
a pure restriction with no behavior change to what was actually tested.
@jfallows
jfallows force-pushed the feature/avro-model-disclosure branch from 71a32b4 to f018d27 Compare August 14, 2026 07:16
@jfallows
jfallows merged commit 7bfcec4 into develop Aug 14, 2026
82 checks passed
jfallows added a commit that referenced this pull request Aug 16, 2026
…peline stages (#2385)

* feat(model-json): add JsonModelExtFactorySpi for provider-supplied pipeline stages

Mirrors model-avro's AvroModelExtFactorySpi (#2376/#2377): a generic,
business-agnostic extension point so an installed module can contribute
its own pipeline stage to the json model without the engine or model-json
knowing anything about what that stage does.

- JsonTransformable in common-json (JsonStream now extends it), the
  narrower supertype an extension appends stages to without depending on
  JsonStream's fuller terminal-bearing API
- JsonModelExt/JsonModelExtContext/JsonModelExtFactorySpi/JsonModelExtHandler
  in model-json's new io.aklivity.zilla.runtime.model.json.ext package;
  JsonModelHandlerImpl folds every discovered extension's stage into the
  decode stream ahead of the model's own validator/extractor stages, in
  discovery order. Encode never folds extensions in: it is the write path
  into the broker and must preserve the full, undisclosed value.
- JsonModelExtHandler.padding(schema) (default 0) lets an extension declare
  the maximum additional bytes its transform may add to a decoded value, so
  KafkaCachePartition's existing bounds check (already generic across
  models) reserves enough converted-value capacity regardless of which
  model triggered the shortfall
- A deployment with zero installed extensions pays nothing: the fold is a
  no-op and the assembled pipeline carries no extra stage

Fixes #1682

* fix(model-json): allow provider-supplied model-ext properties in options.value

json.schema.patch.json closed options.value with additionalProperties:
false at the top level, so no ModelExtInfo-contributed property (the
existing per-model extension point, already used successfully by
model-avro's own schema patch, which carries no such restriction) could
ever validate against a model:json options block -- any add to
$defs/models/model/allOf from a separate schema patch is rejected
outright by this branch's own closure, regardless of what that branch
itself permits.

Drop the blanket additionalProperties:false, matching model-avro's
schema shape; the enclosing $defs/models/model schema already closes
via unevaluatedProperties:false, so undeclared keys are still rejected
once every contributing allOf branch is considered together.

* fix(model-json,common-json): decode pipeline correctly supports installed extensions

Two latent bugs, both invisible until a value model extension actually
substitutes a value through a live decode pipeline:

- JsonModelDecoderPipeline computed its source-side "skip this many
  bytes of catalog framing" prefix by calling the handler's decodePadding,
  which folds in every installed extension's own padding contribution
  (destination-sizing, for a value an extension may expand) -- not the
  catalog's own framing-byte count. Once an extension contributes
  non-zero padding, that count got skipped from the actual input instead,
  truncating the value before the parser ever saw it. Split out a
  dedicated prefix() on JsonModelHandlerImpl (catalog framing only,
  mirroring model-avro's own prefix()/decodePadding() split) and pointed
  the decoder at it.

- JsonStream's generator-owning into(JsonGeneratorEx) terminal always
  requests byte-preserving delivery, so a value that substitutes content
  (rather than reproducing the parsed input) gets asked for the original
  source bytes it does not have -- the substitute source implementations
  installed models are expected to supply do not exist as bytes at all.
  into(JsonSink) already exposes a structured-delivery opt-out via
  JsonEx.createSink's config param; add the matching config-taking
  into(JsonGeneratorEx, Map) overload so the repeatedly-invoked,
  re-targeted terminal a decode pipeline needs can opt out the same way.
  model-json's decode pipeline now requests structured delivery once any
  extension is installed, unchanged otherwise.

* fix(engine): TestBindingFactory correctly drives ModelPipeline across fragments

TestBindingFactory's model transform loop only ever handled ModelStatus.OK
and COMPLETE, leaving ModelStatus.OVERFLOW unhandled entirely -- a value
whose transformed size exceeded modelBuffer's fixed capacity spun forever
against an already-full destination window (silent livelock, no exception).
Now OVERFLOW drains modelBuffer downstream before continuing, delivering
values of any size across as many chunks as needed.

The loop also hardcoded every call's source-side flags to INIT|FIN, so a
value split across multiple onXData invocations presented each continuation
frame as a fresh, complete message to the model -- a stateful pipeline mid
value saw a spurious restart and rejected it as malformed. Source flags now
start at the DATA frame's own actual flags and drop INIT after the first
call, matching how the frame was really fragmented.

Destination accumulation (total bytes produced, whether an OVERFLOW drain
has already happened) now lives in a per-direction ModelTransformState field
instead of a call-local variable, so it persists correctly across separate
onXData invocations for the same logical value instead of resetting on
every call -- and nothing is flushed downstream until the transform session
actually concludes (COMPLETE or REJECTED), matching ModelPipeline's
all-or-nothing contract for a value that only turns out invalid once its
terminal event fires.

* fix(common-json,model-json): self-bound JsonTransformable to avoid a cast

JsonTransformable.transform(JsonTransform) returned the narrower
JsonTransformable supertype, so any caller extending a concrete stream
type (JsonModelHandlerImpl.extend(), folding each installed model
extension's stage into the decode stream) had to cast the result back to
JsonStream to keep building on it.

JsonTransformable now takes a self-bounded type parameter
(T extends JsonTransformable<T>) and returns T instead, mirroring
common-avro's AvroTransformable fix: JsonStream extends
JsonTransformable<JsonStream>, and JsonModelExtHandler.transform() is
generic over the caller's own concrete stream type, so extend() no
longer needs the (JsonStream) cast.

A functional interface with a generic abstract method can't be a lambda
target, so the one JsonModelExtHandler lambda in JsonModelDecoderPipelineTest
(the "drop a field" test double) becomes an anonymous class -- matching
every other JsonModelExtHandler implementation already written that way.

* feat(model-json): split JsonModelExtHandler.transform() into decode()/encode()

model-json's own extension SPI conflated a pipeline decoding the
canonical value into the view delivered to a reader with one encoding
a caller's value into its canonical form under a single transform()
method, and the encoder pipeline never folded installed extensions in
at all. Splitting into decode()/encode() default methods (mirroring
model-avro's AvroModelExtHandler) lets an extension apply to either
direction independently, and lets the encoder pipeline fold installed
extensions in the same way the decoder pipeline already does.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XC96PuggqzqgyXmhUuXEH5

* wip(model-json): mirror model-avro's ModelExt composition test coverage

Adds TestUppercaseJsonModelExtFactorySpi (test-only JsonModelExtFactorySpi,
mirroring TestUppercaseAvroModelExtFactorySpi merged into develop) plus the
matching json.ext.yaml config, JsonFunctions k3po repeat() helper, 24 paired
client/server .rpt scripts under specs/model-json.spec, and 6 new JsonModelIT
test methods covering apply-on-decode/encode, overflow-drain at 100k, and
reject via JsonPipeline.Status.REJECTED.

Fixes a real bug found in the process: JsonModelHandlerImpl's encode-path
newPipeline() didn't force JsonSink.Delivery.STRUCTURED once an extension is
installed, unlike the decode path -- a substituted value has no original
source bytes to splice, so the terminal generator's default byte-preferring
delivery mode crashed the engine worker (UnsupportedOperationException from
getVerbatim()) the moment an extension substituted a value during encode.

Status: NOT yet green. Three of the six new JsonModelIT methods still fail
-- the reply-direction (decode) scenarios show zero events reaching the
extension for the reply value, and the encode-direction 100k scenario stops
short after a couple of transformed characters. Root cause not yet isolated.

Also merged origin/develop (TestBindingFactory reassembly + reply-direction
decode fixes, avro's own now-complete ModelExt composition test suite this
work mirrors). That merge exposed two pre-existing model-json.spec IT
failures unrelated to this change (shouldRejectJsonStrictMissingRequired
Fragmented, shouldRejectJsonAdditionalPropertyFragmented) -- confirmed by
isolated re-run -- caused by the engine's corrected frame reassembly timing
not matching the JSON spec scripts' expected streamed pre-reject output.
Not yet fixed.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XC96PuggqzqgyXmhUuXEH5

* fix(model-json.spec): update fragmented reject scripts for structured delivery

Installing any JsonModelExtFactorySpi makes JsonModelHandlerImpl's exts
list non-empty for every model:json pipeline in the same JVM, forcing
STRUCTURED (canonical re-serialization) delivery globally rather than
byte-preserving splice -- not just for bindings that reference the
extension. Adding TestUppercaseJsonModelExtFactorySpi's test-scope
registration therefore changed the exact streamed pre-reject byte output
of two pre-existing scenarios that predate any extension: a KEY_NAME
event now commits "id": as one atomic re-serialized unit rather than
splicing the raw partial input, and a trailing comma before a still-
pending sibling property is no longer speculatively emitted.

Confirmed via isolated toggling of the extension's META-INF/services
registration that this is the actual cause (both tests pass with it
absent, fail identically with it present) -- not a stale rebuild.
Updated client.sent.json.strict.missing.required.fragmented (partial
output "{\"id\":" instead of "{\"id\"") and
client.sent.json.additional.property.fragmented (partial output
"{\"id\":42,\"status\":\"OK\"" instead of ...\"OK\",\" with a trailing
comma) to the real structured-delivery output, verified against a live
run. Also drops the ENGINE_BUFFER_SLOT_CAPACITY override on JsonModelIT's
shared EngineRule -- unlike AvroModelIT's own dedicated instance, this
one is shared by every test method in the class, including these two,
so it was an unnecessary and risky change to make just for the new ext
scenarios.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XC96PuggqzqgyXmhUuXEH5

* fix(model-json): resolve schema-id-0 ambiguity and buffer capacity for ext tests

json.ext.yaml's test catalog had no explicit numeric id, defaulting to 0 --
colliding with CatalogHandler.NO_SCHEMA_ID. JsonModelDecoderPipeline treats
schemaId == NO_SCHEMA_ID as "no schema resolved" and rejects outright, so
every reply-direction decode (which resolves via resolve(subject, version),
falling back to the catalog's own configured id when the subject isn't
dynamically registered) was rejected before ever reaching the installed
extension. Adding id: 1 (matching avro.ext.yaml's own convention) fixes it:
shouldApplyExtensionOnDecode and shouldApplyExtensionOnEncode now pass.

Restores JsonModelIT's ENGINE_BUFFER_SLOT_CAPACITY override (removed in the
previous commit): confirmed via a full local run that it doesn't affect the
two fragmented-reject tests after all -- their scripts declare an 8192-byte
window, well under either the 32768-byte default or the 65536-byte override,
so neither clamps it. The 100k-scale scenarios do need it: without it, the
reply-direction test crashed the engine worker with an IndexOutOfBoundsException
in TestBindingFactory's own reply-window drain (limit beyond maxLimit) --
this override eliminates that crash.

Status: shouldApplyExtensionOnDecode, shouldApplyExtensionOnEncode, and both
reject scenarios now pass -- 4 of 6 new tests green, no crashes, no
regressions in the rest of the suite (verified via full clean install).
The two 100k-scale scenarios (shouldDrainExtensionOverflowOnDecode/EncodeAcrossMultipleFrames)
still fail: the extension's captured buffer ends up with 165,535 characters
instead of 100,000 -- exactly 65,535 (2^16-1) more, matching the buffer slot
boundary -- pointing to a duplication interaction between the engine's own
slot-drain/resume cycling and the extension's own SUSPENDED/resume handling
for a value whose transformed output spans multiple frames. Not yet
isolated to a single root cause; separate from the schema-id and delivery-
mode fixes above.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XC96PuggqzqgyXmhUuXEH5

* fix(model-json): re-capture, not append, deferred string fragments in test ext

JsonSource#getStringView() delivers the value's whole decoded-so-far
prefix on every fragment of a deferred (over-window) string, not a
delta -- confirmed against JsonExtractor's own handling of the same
contract. TestUppercaseJsonModelExtFactorySpi's onTargetString wrongly
treated each fragment as an increment to append, duplicating the
already-captured prefix on the final fragment. Re-capture (overwrite)
on every fragment instead, matching JsonExtractor's established
pattern, fixing the two 100k-scale drain scenarios.

---------

Co-authored-by: Claude <[email protected]>
jfallows added a commit that referenced this pull request Aug 16, 2026
…pipeline stages (#2380)

* feat(model-protobuf): add ProtobufModelExt SPI for provider-supplied pipeline stages

Mirrors model-avro's AvroModelExt SPI (#2376) exactly, substituting Protobuf
for Avro throughout. Adds ProtobufTransformable to common-protobuf (the
narrower supertype ProtobufStream now extends) and a new
io.aklivity.zilla.runtime.model.protobuf.ext package
(ProtobufModelExtFactorySpi/ProtobufModelExt/ProtobufModelExtContext/
ProtobufModelExtHandler). ProtobufModelHandlerImpl folds every discovered
extension's handler into the decode-only pipeline, ahead of its own
extractor stage, and sums each extension's declared padding() contribution
into the Kafka cache capacity estimate. A deployment with zero installed
extensions pays nothing.

Fixes #1683

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QiMcyVBhRqf8cEmVadRAZ8

* fix(model-protobuf): let model extensions contribute schema properties

The protobuf model's own allOf branch restricted itself with a local
additionalProperties: false, which is evaluated purely against that
branch and can never see properties contributed by a sibling allOf
branch such as an installed model extension's schema patch (already
merged for model-avro's equivalent AvroModelExtFactorySpi). Since the
model extension SPI's whole point is letting an installed module
contribute additional per-model config, a locally-scoped
additionalProperties: false silently blocks every such contribution.

Remove the redundant local restriction; the shared
unevaluatedProperties: false on $defs/models/model (added for
model-avro) already enforces the same closed-schema guarantee while
seeing annotations from every allOf branch, including extension-
contributed ones.

* test(model-protobuf): verify ext composition via a test-only extension

Adds a src/test-only TestUppercaseProtobufModelExtFactorySpi, registered
solely under META-INF/services so it never ships in the production jar,
proving the ProtobufModelExtFactorySpi composition mechanism works
end-to-end through a live engine -- independent of any specific installed
extension. It uppercases scalar string field values unconditionally, with
no configuration of its own, mirroring the ProtobufModelExtDisclosureTransform
withhold-then-substitute pattern over the same ProtobufTransform contract.

New client.received.protobuf.{json,binary}.ext.uppercase scenarios drive
this through ProtobufModelIT's reply-direction decode path (the only
direction extensions attach to), plus their NetworkIT/ApplicationIT
self-consistency pairs.

Fixes a schemaId=0/NO_SCHEMA_ID collision in value.view.json.yaml and
value.binary.yaml: the test catalog's own resolved id defaulted to the
same sentinel used for "unresolved", so a legitimately-resolved schema on
the decode path was discarded as if no schema had been found. An explicit
catalog id avoids the collision, matching the same fix already applied to
model-avro's equivalent test config.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QiMcyVBhRqf8cEmVadRAZ8

* fix(model-protobuf): exclude test-only ext fixture from published test-jar

TestUppercaseProtobufModelExtFactorySpi and its META-INF/services
registration exist solely to prove the ProtobufModelExtFactorySpi
ServiceLoader composition mechanism in this module's own ProtobufModelIT.
The test-jar packaged everything under target/test-classes with no
curation, so any consumer depending on model-protobuf:test-jar (e.g. a
real installed protobuf model extension's own test suite) picked up this
fixture too -- and since ProtobufModelExt implementations are discovered
and applied unconditionally, its unconditional uppercase transform
silently stacked on top of that consumer's own extension.

Excludes the fixture's class and service registration from the test-jar
so it stays local to this module's own build, mirroring the curated
test-jar packaging convention already used for the engine module's own
type: test SPI implementations.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QiMcyVBhRqf8cEmVadRAZ8

* refactor(model-protobuf): follow ProtobufTransformable's self-bounded transform() signature

ProtobufTransformable<T extends ProtobufTransformable<T>> is now self-bounded,
so ProtobufModelExtHandler.transform() returns the caller's own concrete
stream type instead of the narrower ProtobufTransformable supertype.
Mechanical signature update only, no behavior change. ProtobufModelHandlerImpl
no longer needs to cast the extended stream back to ProtobufStream, and test
doubles that mocked ProtobufTransformable now mock ProtobufStream instead,
since a raw ProtobufTransformable mock can no longer bind to the generic
parameter without an unchecked cast.

Mirrors AvroTransformable's identical self-bounded-generic refactor.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QiMcyVBhRqf8cEmVadRAZ8

* fix(model-protobuf): split ProtobufModelExtHandler by decode/encode direction

ProtobufModelExtHandler.transform(T stream) had no notion of which
direction it was extending, so ProtobufModelHandlerImpl.extend() folded
every installed extension's stage into the decoder pipeline only --
the encoder pipeline built its stream without any extension folding,
and encodePadding() never accounted for extension padding. A future
extension that must transform both directions (e.g. one applied
symmetrically on write and read) had no way to do so.

Split into decode(T transformable) / encode(T transformable), each
defaulting to a pass-through, mirroring the decode/encode-suffixed
members ProtobufModelHandler already exposes (decodeLenient/encodeLenient,
decodePadding()/encodePadding()) rather than threading a boolean flag
through a single method. ProtobufModelHandlerImpl.extend() is split the
same way into extendDecode()/extendEncode(), each backing the matching
newPipeline() overload; encodePadding() now sums the extension padding
contribution the same way decodePadding() already did.

Updates the two existing client.received.protobuf.*.ext.uppercase IT
scripts: their application-side scripts previously assumed the encode
leg (network client's request reaching the application) passed through
untransformed, which is no longer true now that installed extensions
fold into the encoder pipeline too.

Mirrors AvroModelExtHandler's identical decode/encode split.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QiMcyVBhRqf8cEmVadRAZ8

---------

Co-authored-by: Claude <[email protected]>
@jfallows
jfallows deleted the feature/avro-model-disclosure branch August 16, 2026 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants