Skip to content

engine: add Config/ConfigBuilder extension mechanism - #2363

Merged
jfallows merged 15 commits into
developfrom
claude/zilla-issue-2360-9pmexc
Aug 13, 2026
Merged

jfallows merged 15 commits into
developfrom
claude/zilla-issue-2360-9pmexc

Conversation

@jfallows

Copy link
Copy Markdown
Contributor

Description

Adds a Config/ConfigBuilder extension mechanism so a config object owned by one module can carry a named, optional value whose concrete Java type is supplied by an installed provider module, without the defining module taking a compile-time dependency on it or knowing the extension's name in advance.

  • Config — shared root for config value objects; holds a Map<String, Config> of named extensions (null when absent) with a typed ext(name, type) getter.
  • ConfigBuilder (existing class, extended) — adds a fluent ext(factory) for composing a nested ConfigExtBuilder, plus a package-private ext(name, value) reachable by ConfigExtAdapter for the already-parsed case.
  • ConfigExtBuilder — base for a concrete extension's nested builder; deliberately not a ConfigBuilder subtype since its build() returns the outer builder, not the value.
  • ConfigInfo / ConfigExtInfo / ModelExtInfo — SPI shapes for discovering ModelInfo and its extensions via ServiceLoader.
  • ConfigExtAdapter — plain utility mapping named JSON sub-objects to/from Config extensions; used by any *ConfigAdapter that wants to support extensions.
  • Factory.instantiate(Iterable) — new public list-returning overload, since multiple independent ConfigExtInfo registrations can share the same type() and the existing map-building overload's unique-key assumption would silently drop collisions.
  • Wires the mechanism through ModelInfo/ModelExtInfo and the Avro/Json/Protobuf model config adapters, per the issue's scope (AvroModelConfig/AvroModelConfigAdapter/AvroModelInfo never reference any concrete extension type).
  • Pre-seeds the model-ext schema scaffold in the engine's base schema (engine.schema.json), mirroring the existing binding-ext convention documented in specs/AGENTS.md.

Unit test coverage added for: Config.ext, ConfigBuilder.ext(factory) composition, ConfigExtAdapter.adaptToJson/adaptFromJson round-tripping through real Config/ConfigBuilder subtypes (including a subtype-builder case exercising the generic-variance subtlety), Factory.instantiate(Iterable)'s incubating filter, and ModelInfo.extensions() filtering by type().

This lands entirely within config/engine.conf plus the three model config modules — no new module. General-purpose engine infrastructure, not encryption-specific; required by #1681 §5.

Fixes #2360

Test plan

  • ./mvnw test -pl config/engine.conf,config/model-avro.conf,config/model-json.conf,config/model-protobuf.conf — all existing and new unit tests pass
  • ./mvnw checkstyle:check and ./mvnw license:check on the touched modules
  • ./mvnw jacoco:report jacoco:check on the touched modules — coverage thresholds met
  • specs/engine.spec SchemaTest passes with the new model-ext schema scaffold

Generated by Claude Code

claude added 4 commits August 12, 2026 19:09
Adds ConfigInfo, ConfigExtInfo, ConfigExtAdapter and a Config/ConfigBuilder
base pair so a config object owned by one module can carry a named,
optional value whose concrete type is supplied by an installed provider
module, without the defining module depending on the provider.

Wires the mechanism through ModelInfo/ModelExtInfo and the Avro/Json/
Protobuf model config adapters. Adds Factory.instantiate(Iterable) since
ConfigExtInfo registrations are not keyed uniquely by type() the way
FactorySpi-based lookups are. Pre-seeds the model-ext schema scaffold in
the engine base schema, mirroring the existing binding-ext convention.

Closes #2360
AvroModelConfigAdapter, JsonModelConfigAdapter, and ProtobufModelConfigAdapter
implement ModelConfigAdapterSpi, which the engine discovers via
ServiceLoader — a mechanism that requires a public no-arg constructor.
Requiring a List<ModelExtInfo> in the sole constructor broke that
reflection-based instantiation path (ServiceConfigurationError at runtime).

Add back a public no-arg constructor that discovers ModelExtInfo providers
itself, matching what ModelInfo.extensions() would compute; the two-arg
constructor remains for ModelInfo.adapter() (which already has the
extensions list) and for tests.
AvroModelConfigAdapter, JsonModelConfigAdapter, and ProtobufModelConfigAdapter
now call ServiceLoader.load(ModelExtInfo.class) directly from their own
module-info.avro/json/protobuf module, but only engine.conf's module-info
declared `uses ModelExtInfo`. Under the real module path (as opposed to
Surefire's unnamed-module test classpath, where `uses` isn't enforced),
this throws ServiceConfigurationError the moment any binding eagerly
constructs a ModelConfigAdapter — which happens unconditionally at engine
startup, breaking every packaged Docker image regardless of the configured
zilla.yaml.

Reproduced locally by running the actual engine on a hand-assembled module
path mirroring the zpm-built runtime image; confirmed the fix resolves it
by constructing ModelConfigAdapter directly on the module path before and
after the change.
Replaces the raw ConfigExtAdapter return type plus a covariant-override
in ModelExtInfo with a proper type parameter on ConfigExtInfo<T extends
Config>, matching the Comparable<T> idiom. ModelExtInfo now just fixes
T = ModelConfig and goes back to being an empty marker interface; every
call site (ModelExtInfo::adapter, the List<ConfigExtAdapter<ModelConfig>>
wiring in the Avro/Json/Protobuf adapters) already resolves the same way
since the generic substitution supplies the exact signature they relied
on the covariant override for.

@jfallows jfallows left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

claude added 11 commits August 12, 2026 23:06
Extends BindingConfig, ConditionConfig, OptionsConfig, WithConfig,
CatalogConfig, GuardConfig, ExporterConfig, VaultConfig, StoreConfig, and
McpToolSearchIndexConfig from Config, cascading to every leaf *Config value
class built via ConfigBuilder. Remaining leaf classes with no prior
superclass now extend Config directly.

This establishes a uniform baseline so any *Config value can opt into the
Config.ext(name, type) extension mechanism added for #2360, without wiring
up ConfigExtInfo/ConfigExtAdapter SPI or schema patches for these families
yet - that remains a per-family follow-up.

ConfigBuilder<T, B> itself is left unbounded: many builders in
config/engine.conf (BindingConfigBuilder, NamespaceConfigBuilder,
AttributeConfigBuilder, etc.) reuse T as a continuation type returned to a
parent builder via a mapper, not as the Config value being built, so a
uniform T extends Config bound is incompatible with that pattern as
designed.

Verified with a full reactor build (compile + checkstyle + unit tests) and
by running the packaged Docker image against the http.echo and
http.kafka.avro.json examples end to end.

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

Add ConfigBuilder.Extensible<T, B> as a nested class carrying the
.ext(...)/extensions() machinery previously on ConfigBuilder itself.
AvroModelConfigBuilder, JsonModelConfigBuilder, and ProtobufModelConfigBuilder
(the only builders that currently wire extensions() into their built value)
now extend Extensible instead of plain ConfigBuilder; ConfigExtAdapter's
adaptFromJson is scoped to Extensible builders accordingly.

Extensible stays unbounded in T, same as ConfigBuilder - these model
builders are nested elsewhere via their generic factory (e.g.
AvroModelConfig::builder passed into KafkaTopicConfigBuilder.key() in the
asyncapi/openapi composite generators), where T resolves to a continuation
builder type, not a Config. Bounding T to Config broke that nesting; since
.ext()/extensions() only ever touch the builder's own internal map and the
actual Config-compatibility guarantee already comes from each build()
method's own constructor call, no bound was needed for correctness in the
first place.

This replaces the ConfigBuilder<T extends Config, B> approach from the
prior commit: rather than requiring every *Config value class extend
Config for a compile-time bound on ConfigBuilder, extension support is now
opt-in per builder via Extensible, with no impact on the ~150 other
builders in the config API.

Verified with a full reactor build (compile + checkstyle + unit tests) and
by rebuilding the Docker image and running the http.kafka.avro.json example
end to end (schema registration, JSON-to-Avro produce) against it.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013emf9JB5HYnof31hnLfBdb
AsyncapiCatalogConfig, AsyncapiSpecificationConfig, and OpenapiCatalogConfig
picked up extends Config in the config-baseline refactor, pulling a new
engine.conf dependency into runtime/common-asyncapi and
runtime/common-openapi. Those common-* modules are meant to be low-level,
broadly-depended-on shared libraries; depending on config.engine inverts
that layering for no current benefit, since neither class is ever built via
a ConfigBuilder.Extensible or otherwise uses the extension mechanism.

Reverts the class changes, the engine.conf pom.xml dependency, and the
module-info.java requires in both modules, and regenerates NOTICE via
mvnw notice:generate per repo convention.

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

Move the extensions map and ext(name, type) accessor off the base Config
class into a nested Config.Extensible, mirroring the ConfigBuilder /
ConfigBuilder.Extensible split. Plain Config is now just a marker type;
only classes whose constructor actually threads an extensions map extend
Extensible and gain .ext(...) - previously every *Config subclass inherited
ext(), but for the ~240 without an extensions-accepting constructor it
could only ever return null.

ModelConfig and the TestRootConfig test fixture now extend
Config.Extensible instead of Config; ConfigExtInfo and ConfigExtAdapter's
T bound tightens from Config to Config.Extensible to match, since both
already require a type capable of holding named extensions.

Verified with a full reactor build (compile + checkstyle + unit tests) and
by rebuilding the Docker image and running the http.kafka.avro.json
example end to end.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013emf9JB5HYnof31hnLfBdb
Introduces ConfigAdapter<T extends Config> implements JsonbAdapter<T, JsonValue>
as the third piece of the Config/ConfigBuilder/ConfigAdapter symmetry, with a
nested Extensible<T extends Config.Extensible> holding the List<ConfigExtAdapter<T>>
extensions and the adaptExtensionsToJson/adaptExtensionsFromJson dispatch
previously duplicated identically across AvroModelConfigAdapter,
JsonModelConfigAdapter, and ProtobufModelConfigAdapter.

Those three now extend ConfigAdapter.Extensible<ModelConfig>. Their public
constructors take List<ConfigExtAdapter<ModelConfig>> instead of
List<ModelExtInfo> - the ModelExtInfo -> ConfigExtAdapter extraction moves
into AvroModelInfo/JsonModelInfo/ProtobufModelInfo's own adapter() methods,
so the config adapters no longer need ModelExtInfo in their public API,
only in the no-arg ServiceLoader-compatible constructor kept for
ModelConfigAdapterSpi's direct ServiceLoader instantiation.

The six core model adapters (model-core.conf), MetricConfigAdapter,
MetricRefConfigAdapter, engine.conf's ModelConfigAdapter dispatcher, and the
TestModelConfigAdapter test fixture now extend plain ConfigAdapter<T>
instead of implementing JsonbAdapter<T, JsonValue> directly - these are the
only classes in the repo implementing that exact shape; every other
*ConfigAdapter targets JsonObject, not JsonValue, and is unaffected.

Verified with a full reactor build (compile + checkstyle + unit tests) and
by rebuilding the Docker image and running the http.kafka.avro.json example
end to end.

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

Generalizes ConfigAdapter<T extends Config, A> implements JsonbAdapter<T, A>
with a second type parameter for the adapted JSON shape (previously hardcoded
to JsonValue). Model/metric adapters that already extended it now specify
ConfigAdapter<X, JsonValue> / ConfigAdapter.Extensible<X, JsonValue>
explicitly.

Migrates the remaining 113 *ConfigAdapter classes across ~40 modules
(config/*.conf, incubator/binding-risingwave.conf, incubator/binding-amqp.conf)
from directly implementing JsonbAdapter<T, JsonObject> to extending
ConfigAdapter<T, JsonObject>, completing repo-wide coverage of the
Config/ConfigBuilder/ConfigAdapter trio: every *Config class extends Config
or Config.Extensible, every *ConfigBuilder extends ConfigBuilder or
ConfigBuilder.Extensible, and now every applicable *ConfigAdapter extends
ConfigAdapter or ConfigAdapter.Extensible.

AbstractSchemaRegistryOptionsConfigAdapter<T> (catalog-schema-registry.conf)
is a special case: it keeps its own generic parameter (used for its
non-adapter factory methods) while separately extending
ConfigAdapter<OptionsConfig, JsonObject> for the JsonbAdapter shape.

Two classes are deliberately excluded, since neither adapts a bare Config
value: CatalogedConfigAdapter (adapts List<CatalogedConfig>), and
KindConfigAdapter / OtlpSignalsAdapter (adapt KindConfig via JsonString and
a Set<OtlpSignalsConfig> via JsonArray, respectively).

Verified with a full reactor build (compile + checkstyle + unit tests) and
by rebuilding the Docker image and running the http.kafka.avro.json example
end to end.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013emf9JB5HYnof31hnLfBdb
ModelInfo.adapter() already returns the same JsonbAdapter<ModelConfig, JsonValue>
that ModelConfigAdapterSpi provided, and every module with a
ModelConfigAdapterSpi provider already registers a matching ModelInfo too -
the two SPIs were redundant duplicates of the same registration.

ModelConfigAdapter's dispatcher now discovers adapters via
ServiceLoader.load(ModelInfo.class) (mirroring Factory.instantiate usage
elsewhere) instead of ModelConfigAdapterSpi, keyed by ModelInfo::type and
built via ModelInfo::adapter. Since it now holds a raw
JsonbAdapter<ModelConfig, JsonValue> delegate instead of the narrower
ModelConfigAdapterSpi (which declared its adaptToJson/adaptFromJson without
the checked Exception JsonbAdapter itself declares), the two dispatch
methods now catch and rethrow as IllegalArgumentException, matching the
existing ConfigExtAdapter pattern.

AvroModelConfigAdapter, JsonModelConfigAdapter, and ProtobufModelConfigAdapter
lose their no-arg constructors - those existed solely to satisfy
ModelConfigAdapterSpi's direct ServiceLoader instantiation, and nothing
called them directly (only the corresponding *ModelInfo.adapter() method
constructs them, via the parameterized constructor). The six model-core.conf
adapters and TestModelConfigAdapter drop `implements ModelConfigAdapterSpi`;
their type() methods stay as private helpers where actually called
internally (model-core's adaptToJson bodies self-invoke type()), removed
where dead (Avro/Json/Protobuf use a local constant directly instead).

Removes ModelConfigAdapterSpi.java, its uses/provides declarations from
engine.conf and the four model modules' module-info.java, and the five
now-unreferenced META-INF/services/...ModelConfigAdapterSpi resource files.

Verified with a full reactor build (compile + checkstyle + unit tests) and
by rebuilding the Docker image and running the http.kafka.avro.json example
end to end.

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

BindingInfo/GuardInfo/VaultInfo/CatalogInfo/StoreInfo/ExporterInfo now
return ConfigAdapter<X,Y> instead of the raw JsonbAdapter<X,Y> from
options()/condition()/with(), so every aggregator adapter downstream
(BindingConfigAdapter, RouteConfigAdapter, GuardConfigAdapter,
VaultConfigAdapter, CatalogConfigAdapter, StoreConfigAdapter,
ExporterConfigAdapter, TelemetryConfigAdapter, NamespaceConfigAdapter)
drops its throws Exception instead of working around it.

Inline CatalogedConfigAdapter into BindingConfigAdapter, mirroring how
RouteConfigAdapter handles guarded inline, and delete the standalone
class. This also fixes a round-trip bug where adaptToJson wrapped the
catalogs object in a one-element JSON array while adaptFromJson
expected a bare object.

Drop the now-pointless private type() wrappers in the core model
adapters in favor of using their constants directly, and rename
ConfigAdapter.Extensible's adaptExtensionsToJson/adaptExtensionsFromJson
to the overloaded injectExtensions, using ConfigBuilder.inject to keep
the fromJson path fully fluent instead of reassigning a local builder
variable.

Verified with a full reactor build, a rebuilt docker image, and live
runs of the grpc.echo (binding-level catalog config) and
http.kafka.avro.json (model-level catalog + full produce/fetch round
trip) examples.
injectExtensions(JsonObject, B) already mutates and returns the same
builder instance (ConfigBuilder.Extensible.ext() just casts and returns
this), so the .inject(b -> injectExtensions(object, b)) wrapper in the
Avro/Json/Protobuf model adapters was unnecessary ceremony -- call it as
a plain statement instead.

Use .toList() instead of .collect(toList()) in ModelInfo.extensions() and
the three model adapters' constructors.
…s touched by this PR

Same brevity cleanup requested in review, applied to the remaining
.collect(toList()) call sites in files this PR already touches:
McpKafkaConditionConfigAdapter, TlsOptionsConfigAdapter,
AbstractSchemaRegistryOptionsConfigAdapter, OtlpOptionsConfigAdapter,
FileSystemStoreConfigAdapter.
@jfallows
jfallows merged commit 618bc7b into develop Aug 13, 2026
42 checks passed
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.

engine: add Config/ConfigBuilder extension mechanism (ConfigInfo, ConfigExtInfo, ConfigExtAdapter)

2 participants