Skip to content

feat: mutation hooks system#28

Merged
DarlingtonDeveloper merged 1 commit into
mainfrom
feat/mutation-hooks
Mar 14, 2026
Merged

feat: mutation hooks system#28
DarlingtonDeveloper merged 1 commit into
mainfrom
feat/mutation-hooks

Conversation

@DarlingtonDeveloper
Copy link
Copy Markdown
Contributor

Summary

  • Introduces MutationHook trait and HookRegistry in cortex-core for node/edge write callbacks
  • Hooks are called synchronously after mutations in both library mode (Cortex) and server mode (gRPC service)
  • Provides the foundation for SSE event streaming (#feat/sse-events), future WASM plugins, and computed fields

Changes

  • crates/cortex-core/src/hooks/mod.rs (NEW) — trait, registry, 5 unit tests
  • crates/cortex-core/src/api.rs — hooks field on Cortex, called after store() and create_edge()
  • crates/cortex-core/src/lib.rs — module + re-exports
  • crates/cortex-server/src/grpc/service.rs — hooks called after all 5 write operations
  • crates/cortex-server/src/serve.rs — HookRegistry initialization

Test plan

  • 5 new unit tests (registration, node/edge mutation dispatch, multiple hooks, action types)
  • cargo test --workspace passes (all 327 tests)
  • cargo clippy --workspace clean

🤖 Generated with Claude Code

Introduces a MutationHook trait and HookRegistry that enables callbacks
after node/edge mutations (create, update, delete). Hooks are called
synchronously in the write path and provide the foundation for SSE
event streaming and future WASM plugins.

- New hooks module in cortex-core with MutationHook trait
- HookRegistry dispatches to all registered hooks in order
- Cortex (library mode) calls hooks after store() and create_edge()
- gRPC service calls hooks after all 5 write operations
- Server initializes shared HookRegistry passed to gRPC service

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DarlingtonDeveloper DarlingtonDeveloper merged commit b4a29e3 into main Mar 14, 2026
2 of 3 checks passed
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