27 Commits

Author SHA1 Message Date
Daniel Pupius
8130158c1e feat(cache): priority-based eviction with age protection and Bélády approximation
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>
2026-03-15 20:23:50 +00:00
Daniel Pupius
1d61a89505 fix: remove dead code, SSE error handling, bounded dedup maps
- 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>
2026-03-15 16:27:57 +00:00
Daniel Pupius
df7df6dbd6 Unique client id and fix graceful shutdown 2025-05-04 13:26:13 -07:00
Daniel Pupius
c53486414f Fix static style serving in prod 2025-05-02 15:31:14 -07:00
Daniel Pupius
ba9c8d9221 Channel name cleanup 2025-05-02 15:21:50 -07:00
Daniel Pupius
0279d5fcd4 Static file fallback for entry pages in prod 2025-05-02 15:15:48 -07:00
Daniel Pupius
2692b2e9af Track active connections 2025-05-02 14:39:57 -07:00
Daniel Pupius
e9fa0104e3 Docker set up and fixes for build 2025-05-01 15:34:16 -07:00
Daniel Pupius
68fc353673 Info page 2025-04-30 15:08:03 -07:00
Daniel Pupius
ebb4e1306f Add connection heartbeat 2025-04-30 10:24:55 -07:00
Daniel Pupius
81892a5793 Cache recent packets and send to client when it connects 2025-04-25 17:22:36 -07:00
Daniel Pupius
acaeeaf495 Fix map view on node details 2025-04-25 10:27:44 -07:00
Daniel Pupius
4a41b0062d Cleanup error handling 2025-04-25 09:34:51 -07:00
Daniel Pupius
86e6f45d5e Fixes for node links and early stream connection 2025-04-25 08:46:30 -07:00
Daniel Pupius
0184cba1ef Updates to node details 2025-04-24 20:10:56 -07:00
Daniel Pupius
d04f52d379 Add a dashboard showing observed nodes and gateways 2025-04-24 09:59:06 -07:00
Daniel Pupius
71e914b05d Fixing wireformat for SSE 2025-04-22 13:37:07 -07:00
Daniel Pupius
6844d575c4 Initial skeleton for web application 2025-04-22 13:26:35 -07:00
Daniel Pupius
86380cccf9 Refactor protos 2025-04-21 15:40:10 -07:00
Daniel Pupius
41ee61b59a Updated logging configuration for dev and json for prod 2025-04-21 14:16:35 -07:00
Daniel Pupius
0f151c31b9 Improve structured logging for better log aggregation
- Add message type prefix in brief mode for quick identification
- Include GatewayID in brief mode summary
- Remove formatted output from structured fields
- Use proper structured fields for each message type
- Add common fields like hopLimit and ID for all messages
- Extract specific data for position, telemetry, and text messages
- Format structured data for better log aggregation compatibility
2025-04-21 11:52:40 -07:00
Daniel Pupius
c6d94b10d1 Inject loggers from main.go instead of creating them locally
- 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
2025-04-21 11:09:27 -07:00
Daniel Pupius
9447f44139 Update logging to use prefab/logging package
- 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
2025-04-21 11:01:45 -07:00
Daniel Pupius
9c438713de Add graceful shutdown for SSE connections
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>
2025-04-21 10:38:59 -07:00
Daniel Pupius
52ed85ed23 Send complete packet object to SSE clients 2025-04-21 10:13:30 -07:00
Daniel Pupius
ed1e719bca Add SSE endpoint for streaming MQTT messages to web browsers 2025-04-21 10:01:05 -07:00
Daniel Pupius
758aaa0dc0 Add web server using prefab framework 2025-04-21 09:53:04 -07:00