Skip to content

Conversation

@antweiss
Copy link
Collaborator

This finally brings the ability to support multiple event sources.

the implementation is described here: https://github.com/kagent-dev/khook/blob/feature/extensible-event-sources/docs/flexible-event-sources.md

This is a big change, so let's take it slowly.

An example event source for redis pub/sub is implemented here: https://github.com/kagent-dev/khook/tree/feature/extensible-event-sources/examples/redis-event-source and is demoed here: https://www.youtube.com/watch?v=qdRUvlAs5CI

@antweiss antweiss force-pushed the feature/extensible-event-sources branch 2 times, most recently from bafdeb2 to 59e560c Compare January 14, 2026 09:39
Signed-off-by: Ant Weiss <anton@otomato.io>
- Fixed signature calculation to include source.events prompts
- Added retry mechanism for hook status updates to handle resource version conflicts
- Added comprehensive tests for signature calculation
- Added debug logging for signature comparison

Signed-off-by: Ant Weiss <anton@otomato.io>
- Changed Event.Metadata from map[string]string to map[string]interface{} for flexibility
- All Kubernetes-specific fields (ResourceName, Namespace, Reason) are now optional
- Smart deduplication: prefers UID, falls back to resource/namespace keys
- Enhanced template system: full access to metadata via {{.Metadata.fieldName}}
- Flexible logging: only logs fields that are present
- Added comprehensive documentation and examples
- All tests passing, fully backward compatible

Signed-off-by: Ant Weiss <anton@otomato.io>
- Changed 'context canceled' error log to info log
- This is expected behavior when hooks are updated and workflows restart
- Reduces log noise and confusion

Signed-off-by: Ant Weiss <anton@otomato.io>
…n logging

- Redis event source now automatically moves unknown fields to metadata
- Added debug logging to show original and expanded prompts
- Fixed syntax error in Redis event source

Signed-off-by: Ant Weiss <anton@otomato.io>
- Removed logic that was skipping text/template expansion for metadata fields
- Now {{.Metadata.fieldName}} will be properly expanded
- Added tests for metadata and nested metadata access
- Unknown fields now render as '<no value>' instead of being preserved

Signed-off-by: Ant Weiss <anton@otomato.io>
- Reject events with empty type to prevent invalid processing
- Validate agent reference is not empty before calling
- Validate prompt is not empty before template expansion
- Prevents attempting to call non-existent agents with invalid configurations

Signed-off-by: Ant Weiss <anton@otomato.io>
- Events now deduplicated by content hash instead of ResourceName
- Hash includes: Type, ResourceName, Namespace, Reason, Message, and Metadata
- Metadata keys sorted for deterministic hashing
- Works for any event source (Kubernetes, Redis, IoT, financial, etc.)
- Events with UID still use UID for perfect identification
- Added comprehensive tests for hash stability and collision avoidance

Signed-off-by: Ant Weiss <anton@otomato.io>
Signed-off-by: Ant Weiss <anton@otomato.io>
Signed-off-by: Ant Weiss <anton@otomato.io>
Apply formatting fixes from go fmt:
- Fix indentation in test cases and error handling
- Remove trailing whitespace
- Standardize code formatting across files

Signed-off-by: Ant Weiss <anton@otomato.io>
@antweiss antweiss force-pushed the feature/extensible-event-sources branch from 59e560c to 3ee8954 Compare January 14, 2026 13:42
@antweiss
Copy link
Collaborator Author

@EItanya please take a look

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