Skip to content

feat: add fallback unmarshaler for unknown event types - #1

Merged
MichaelSaucier merged 1 commit into
lovyou-ai:mainfrom
transpara-ai:fix/fallback-unmarshaler
Mar 31, 2026
Merged

feat: add fallback unmarshaler for unknown event types#1
MichaelSaucier merged 1 commit into
lovyou-ai:mainfrom
transpara-ai:fix/fallback-unmarshaler

Conversation

@MichaelSaucier

Copy link
Copy Markdown
Collaborator

Summary

  • Adds RawContent type that preserves unknown event types as raw JSON
  • Adds SetFallbackUnmarshaler() to opt in to graceful handling of unknown types
  • Adds RawFallback — a ready-to-use fallback that wraps unknown events in RawContent

Problem

When multiple subsystems share a Postgres event store (e.g., work-server reading a store that also contains hive/agent events), UnmarshalContent fails 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:

event.SetFallbackUnmarshaler(event.RawFallback)

RawContent implements EventContent — it carries the type name and raw JSON, so the event can be stored, forwarded, and queried without data loss.

Non-breaking

  • No changes to existing behavior unless SetFallbackUnmarshaler is called
  • RawContent.Accept() is a no-op (same pattern as other passthrough content types)
  • All existing tests pass unchanged

Test plan

  • go test ./pkg/event/ passes
  • go vet ./pkg/event/ clean
  • Existing UnmarshalContent behavior unchanged (errors on unknown when no fallback set)

🤖 Generated with Claude Code

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>
@MichaelSaucier
MichaelSaucier merged commit 8d4017b into lovyou-ai:main Mar 31, 2026
21 of 24 checks passed
@MichaelSaucier

Copy link
Copy Markdown
Collaborator Author

Duplicate of #2 — both were auto-merged when the commit was pushed directly to main. Ignore this PR.

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.

1 participant