7 Commits

Author SHA1 Message Date
e66fa40b3a Add ShardManager unit tests
All checks were successful
CI / build (push) Successful in 17s
Comprehensive unit tests for shard management functionality:
- GetShard returns correct shard for actor IDs consistently
- GetShardNodes returns nodes responsible for each shard
- AssignShard correctly updates shard assignments
- PlaceActor returns valid nodes from available set
- Shard assignment handles node failures gracefully
- Replication factor is properly tracked

Includes tests for edge cases (empty shards, nil registry, single node)
and benchmark tests for GetShard, AssignShard, and PlaceActor.

Closes #5

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 22:52:35 +00:00
4666bb6503 Add mutex protection to ConsistentHashRing for thread safety
All checks were successful
CI / build (pull_request) Successful in 16s
- Add sync.RWMutex to ConsistentHashRing struct
- Use Lock/Unlock for write operations (AddNode, RemoveNode)
- Use RLock/RUnlock for read operations (GetNode, GetNodes, IsEmpty)

This allows concurrent reads (the common case) while serializing writes,
preventing race conditions when multiple goroutines access the hash ring.

Closes #35

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 18:46:38 +01:00
b759c7fb97 Fix type assertion bug in handleClusterMessage
All checks were successful
CI / build (pull_request) Successful in 16s
JSON unmarshal produces map[string]interface{}, not concrete types.
Added ModelPayload and MessagePayload concrete types that implement
RuntimeModel and RuntimeMessage interfaces respectively.

The handleClusterMessage now re-marshals and unmarshals the payload
to convert from map[string]interface{} to the proper concrete type.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 16:45:28 +01:00
eaff315782 Replace interface{} with properly defined interfaces
- Add VirtualMachine interface with GetID(), GetActorID(), GetState()
- Add VMState type with idle/running/paused/stopped states
- Add RuntimeModel interface for event storming model contracts
- Add RuntimeMessage interface for actor message contracts
- Add VMProvider interface for decoupled VM access
- Update VMRegistry.GetActiveVMs() to return map[string]VirtualMachine
- Update Runtime interface to use RuntimeModel and RuntimeMessage
- Update DistributedVMRegistry to use VMProvider instead of interface{}
- Add SetVMProvider method to DistributedVM for dependency injection

This improves type safety, makes contracts explicit, and enables better
IDE support while avoiding import cycles through interface segregation.

Closes #37

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 16:45:28 +01:00
c757bb76f3 Make configuration values injectable rather than hardcoded
All checks were successful
CI / build (pull_request) Successful in 16s
CI / build (push) Successful in 15s
Add config structs with sensible defaults for tunable parameters:
- JetStreamConfig for stream retention (1 year) and replica count (1)
- HashRingConfig for virtual nodes per physical node (150)
- ShardConfig for shard count (1024) and replication factor (1)

Each component gets a new WithConfig constructor that accepts custom
configuration, while the original constructors continue to work with
defaults. Zero values in configs fall back to defaults for backward
compatibility.

Closes #38

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 15:33:56 +01:00
3cd4d75e50 Add comprehensive unit tests for ConsistentHashRing
All checks were successful
CI / build (pull_request) Successful in 17s
CI / build (push) Successful in 14s
Test all public methods with 100% coverage:
- AddNode: updates ring, is idempotent, handles multiple nodes
- RemoveNode: updates ring, handles non-existent nodes
- GetNode: returns consistent results, handles empty ring and single node
- GetNodes and IsEmpty helper methods

Distribution tests verify:
- Balanced key distribution across nodes (< 25% deviation)
- Minimal key movement when adding nodes (< 35% moved)
- Virtual nodes improve distribution (CV < 15%)
- Ring behavior with 100+ nodes

Includes benchmarks for GetNode, AddNode, and distribution operations.

Closes #2

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 16:52:34 +01:00
e9e50c021f Initial aether repository structure
All checks were successful
CI / build (push) Successful in 1m13s
Distributed actor system with event sourcing for Go:
- event.go - Event, ActorSnapshot, EventStore interface
- eventbus.go - EventBus, EventBroadcaster for pub/sub
- nats_eventbus.go - NATS-backed cross-node event broadcasting
- store/ - InMemoryEventStore (testing), JetStreamEventStore (production)
- cluster/ - Node discovery, leader election, shard distribution
- model/ - EventStorming model types

Extracted from arcadia as open-source infrastructure component.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-08 19:30:02 +01:00