Skip to content

feat(binding-mqtt)!: require store on mqtt server binding - #1964

Merged
jfallows merged 4 commits into
developfrom
claude/gracious-curie-5avmps-store
Jun 24, 2026
Merged

jfallows merged 4 commits into
developfrom
claude/gracious-curie-5avmps-store

Conversation

@jfallows

Copy link
Copy Markdown
Contributor

Summary

Makes a configured store required on the mqtt binding when kind: server. Store-based MQTT session ownership (introduced in #1806) depends on a store being present; without one the server cannot complete a CONNECT. This is a breaking change targeted at the upcoming major release.

Also exposes options.mqtt.store on the asyncapi binding so the generated mqtt_server0 can be pointed at a shared/cluster-wide store instead of the default minted memory store.

Commits

  1. fix(binding-mqtt): restore memory store on mqtt server session ownership — [2.0] Refactor MQTT session management to use store-based persistence #1806 dropped the memory store from the mqtt.kafka.proxy example and the asyncapi-generated mqtt server; restore it so session ownership works.
  2. feat(binding-mqtt)!: require store on mqtt server binding — mark options + options.store required for kind: server in the schema; drop the now-dead deprecation warning in MqttServerFactory; add a test store to the 17 server spec fixtures; add server.without.store.yaml + shouldRejectServerWithoutStore; declare a memory store on the mqtt.proxy.jwt example.
  3. feat(binding-asyncapi): reference external/cluster store for mqtt options — when options.mqtt.store is set, the server generator references it by qualified name (mirroring the authorization qname pattern) instead of minting mqtt_store0. Adds server.mqtt.store.yaml + shouldValidateMqttStoreServer and an AsyncapiServerIT case exercising the generated composite against an external store.

Testing

Verified locally:

  • binding-mqtt.spec SchemaTest (incl. shouldRejectServerWithoutStore)
  • binding-asyncapi.spec SchemaTest — 12 tests, incl. new shouldValidateMqttStoreServer
  • binding-mqtt unit tests (49) and binding-asyncapi config-adapter tests (8)
  • license + checkstyle clean on changed modules
  • mqtt.kafka.proxy and asyncapi.mqtt.kafka.proxy example smoke tests pass end-to-end against real Kafka with store required; mqtt.proxy.jwt config validates and starts

k3po integration tests (MqttServerIT, AsyncapiServerIT) could not run in the development environment (k3po control agent unavailable) and rely on CI. The engine's type: test store fully implements the session-ownership contract (get/lock/watch/renew, callbacks dispatched on the worker loop), so the store-gated CONNECT completes under the test store.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Vx4B6SkggrTs8EEEenxPtp


Generated by Claude Code

claude added 3 commits June 24, 2026 19:25
PR #1806 dropped the memory store from the mqtt.kafka.proxy example and
from the asyncapi-generated mqtt server binding, but the store-based MQTT
session ownership introduced in that PR requires a store on the mqtt
server binding. Without it the example smoke tests for mqtt.kafka.proxy
and asyncapi.mqtt.kafka.proxy fail to complete the MQTT CONNECT.

- examples/mqtt.kafka.proxy: declare a memory store and reference it from
  the north_mqtt_server binding
- binding-asyncapi: inject a memory store into the generated mqtt_server0
  binding in the server composite namespace

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vx4B6SkggrTs8EEEenxPtp
Session ownership now depends on a configured store, so make the 'store'
option (and therefore 'options') required on the mqtt binding when
kind: server. This is a breaking change targeted at the upcoming major
release.

- mqtt schema: mark options + options.store required for kind: server.
- MqttServerFactory: drop the now-dead 'session ownership will require the
  store option' deprecation warning (and the unused KindConfig import).
- binding-mqtt.spec: add a 'test' store to every mqtt server config that
  lacked one (17 fixtures), add server.without.store.yaml, register the
  engine store test schema patch in SchemaTest, and add
  shouldRejectServerWithoutStore.
- asyncapi: the server generator already injects a memory store for the
  generated mqtt_server0; expose 'store' on the asyncapi mqtt options so it
  can be overridden, defaulting to the generated mqtt_store0.
- examples/mqtt.proxy.jwt: declare a memory store on the mqtt server.

Verified: binding-mqtt + binding-asyncapi unit tests and binding-mqtt.spec
SchemaTest pass; mqtt.kafka.proxy and asyncapi.mqtt.kafka.proxy example
smoke tests pass end-to-end against real Kafka with store required, and the
mqtt.proxy.jwt config validates and starts. k3po integration tests were not
run locally (control agent unavailable in this environment) and rely on CI.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vx4B6SkggrTs8EEEenxPtp
…ions

When options.mqtt.store is set, the asyncapi server generator now references
that store from the enclosing namespace by qualified name (mirroring the
authorization qname pattern) instead of minting a memory store, so operators
can point the generated mqtt server at a shared/cluster-wide store. When
absent, the generator still mints the default mqtt_store0 memory store.

- AsyncapiServerGenerator: resolve options.mqtt.store to a qname via
  supplyQName(resolveId(name)) and inject it on the generated mqtt_server0;
  mint mqtt_store0 only when no external store is configured.
- binding-asyncapi.spec: add server.mqtt.store.yaml fixture (external store
  referenced from options.mqtt.store), register the engine store test schema
  patch, and add shouldValidateMqttStoreServer to SchemaTest.
- binding-asyncapi: add shouldPublishAndSubscribeWithStore to AsyncapiServerIT,
  exercising the generated composite against an external store.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vx4B6SkggrTs8EEEenxPtp

@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

… loop

Store-based session ownership (#1806) assumed asynchronous store
callbacks, driving completeOwnership (and its decodeNetwork) directly
from store.get/lock callbacks. A synchronous store (e.g. the engine
test store) fires those callbacks inline, so the whole ownership chain
ran re-entrantly inside the network decode loop. That re-entrant decode
re-processed the unconsumed CONNECT payload as a second packet, causing
the server to abort the session stream and reply CONNACK 0x82 on a
guarded connect.

Defer ownership acquisition by one tick via a new
SIGNAL_ACQUIRE_SESSION_OWNERSHIP so doAcquireOwnership and the decode
resume always run on a clean signal stack -- never nested in the decode
loop. Consume the CONNECT payload before awaiting ownership so it is not
re-decoded once ownership resolves, and cancel the pending signal on
ownership release.

Configure short session lease/renew on the two server.yaml takeover ITs
(shouldClientTakeOverSession, shouldCloseExistingConnectionCleanStart),
matching shouldTakeOverSession: with a store, takeover steals after
session.renew, whose PT10S default coincides with the 10s test timeout.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vx4B6SkggrTs8EEEenxPtp

@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

@jfallows
jfallows merged commit e8141e9 into develop Jun 24, 2026
41 checks passed
@jfallows
jfallows deleted the claude/gracious-curie-5avmps-store branch July 1, 2026 23:05
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