Replace the flat circular buffer with NodeAwareCache, a smarter eviction
strategy for historical mesh packet data:
- Packets younger than 1 hour are never evicted (recent traffic preserved)
- Under pressure, evict from the lowest-priority type first (neighbor-info
outlasts node-info; chat messages outlast everything)
- Within a priority tier, evict from the most recently active source node —
that node will resend soonest, so its old packet is cheapest to lose
(Bélády approximation; protects flaky/distant node history)
- Node retention window still applies: silent nodes' packets are excluded
from GetAll and pruned proactively before priority eviction runs
Also:
- Add --cache-retention flag (default 3h) and raise --cache-size default to 5000
- Fix decoder error strings (replace verbose Go errors with short codes)
- Add HTTP security headers middleware to server
- Fix broker dispatchLoop deadlock on source channel close
- Fix make gen-proto scanning web/node_modules for .proto files
- Fix tools target always reinstalling protoc-gen-go (handles stale arch binary)
- Move server port from 8080 to 5446; update Dockerfile, docker-compose, moat.yaml
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove unused mustParseDuration from main.go
- Replace http.Error calls after SSE headers with plain returns;
skip bad packets instead of killing the stream on marshal error
- Change processedPackets/seenPackets from boolean to timestamp values
and prune entries older than 24h on each packet to prevent unbounded
memory growth in long-running sessions
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Update all components to accept a logger parameter
- Add default fallbacks when logger is not provided
- Ensure consistent logger naming with parent.Named() pattern
- Create a proper logger hierarchy originating from main.go
- Update MessageLogger to pass logger to BaseSubscriber
- Replace standard log package with prefab/logging
- Add context-aware logging in HTTP handlers
- Add structured logging with fields and levels
- Improve logging hierarchy and namespaces
- Implement named loggers for components
Add atomic shutdown flag and shutdown channel to handle graceful
termination of Server-Sent Events connections. This ensures:
1. New connections are rejected with a proper status code during shutdown
2. Existing connections receive a notification before being closed
3. All subscriber channels are properly unsubscribed from the broker
This implementation safely handles multiple in-flight requests during
shutdown by using an atomic flag to track server state.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>