Skip to content

Add event source and stream definitions with routing resolution - #37

Draft
einari wants to merge 3 commits into
mainfrom
feature/registered-event-sources
Draft

einari wants to merge 3 commits into
mainfrom
feature/registered-event-sources

Conversation

@einari

@einari einari commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Added

  • cratis_chronicle.event_sources: EventSourceDefinition / EventStreamDefinition with ConcurrencyDimensions (wire-matching flag values), name/duplicate validation, and resolve_routing for source/stream routing with explicit-concurrency > stream > source precedence, per-event override and unset source for legacy appends.

Part of #36 (Cratis/Chronicle#4516). Partial — draft: wire registration, definition-aware append and EventContext/observer metadata are blocked, see below. No existing API changed (the package previously exposed only __version__).

Blocker

cratis-chronicle-contracts 16.38.2 has no eventsources module, Chronicle v19.30.0 has no Python contracts asset (publish-python-client is if: false upstream), and the client has no connection/append API yet (#4).

@woksin woksin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One blocking finding in src/cratis_chronicle/event_sources/routing.py (resolve_routing, lines 51-54):

The stream-without-source check looks at the per-event stream argument, not the resolved stream_name. When the stream comes only from the call-level default_stream and no source resolves, the stream is silently dropped instead of rejected:

resolve_routing({}, None, default_stream="Transactions")
# returns ResolvedRouting(event_source=None, event_stream=None, concurrency=None)
# expected: ConflictingEventSourceRoutingError("Stream 'Transactions' was given without an event source")

The docstring says "Without a source nothing is resolved and a stream is rejected", so a defaulted stream should be rejected the same way as a per-event one. Suggested fix: check stream_name is not None (and use it in the message), plus a regression spec for the defaulted-stream case.

Non-blocking: wire registration, append and metadata are still deferred in this PR, so parity with the other clients is partial for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor Backward-compatible capability addition

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants