feat: add fallback unmarshaler for unknown event types - #1
Merged
MichaelSaucier merged 1 commit intoMar 31, 2026
Merged
Conversation
Adds RawContent type and SetFallbackUnmarshaler() so tools sharing a Postgres store with other subsystems (e.g., work-server reading a store that also contains hive/agent/membrane events) can deserialize unknown event types as raw JSON instead of erroring. Use: event.SetFallbackUnmarshaler(event.RawFallback) This is a non-breaking change — default behavior (error on unknown) is preserved unless the fallback is explicitly set. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks
Collaborator
Author
|
Duplicate of #2 — both were auto-merged when the commit was pushed directly to main. Ignore this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RawContenttype that preserves unknown event types as raw JSONSetFallbackUnmarshaler()to opt in to graceful handling of unknown typesRawFallback— a ready-to-use fallback that wraps unknown events inRawContentProblem
When multiple subsystems share a Postgres event store (e.g., work-server reading a store that also contains hive/agent events),
UnmarshalContentfails hard on unknown event types. This forces every tool to import every subsystem's event types, creating tight coupling.Solution
An opt-in fallback unmarshaler. Default behavior (error on unknown) is preserved unless explicitly set:
RawContentimplementsEventContent— it carries the type name and raw JSON, so the event can be stored, forwarded, and queried without data loss.Non-breaking
SetFallbackUnmarshaleris calledRawContent.Accept()is a no-op (same pattern as other passthrough content types)Test plan
go test ./pkg/event/passesgo vet ./pkg/event/cleanUnmarshalContentbehavior unchanged (errors on unknown when no fallback set)🤖 Generated with Claude Code