33 Commits

Author SHA1 Message Date
Daniel Pupius
274eab71c4 chore: go fmt
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-16 17:57:12 +00:00
Daniel Pupius
bd74327515 Retain router position packets mroe aggressively 2026-03-16 10:47:50 -07:00
Daniel Pupius
26a2bba441 Fix network map mobile overflow and infer MQTT hops from SNR=0 (#2)
* Fix network map mobile overflow and infer MQTT hops from SNR=0

- Add min-h-0 and flex-shrink-0 to map layout so legend/actions don't
  overflow the viewport on mobile
- Infer viaMqtt=true for traceroute hops with SNR exactly 0
- Change MQTT hop color from purple to orange across map, legend, and
  node detail badges

https://claude.ai/code/session_01Ffqq7YPCJE28uUFR88eK7C

* Revert MQTT color to purple; keep SNR=0 MQTT inference

The color change was unintended — MQTT hops should stay purple. The
SNR=0 inference in traceroute processing correctly marks those hops
as viaMqtt so they render as purple dashed lines.

https://claude.ai/code/session_01Ffqq7YPCJE28uUFR88eK7C

* Fix test setup: mock URL.createObjectURL for maplibre-gl

maplibre-gl calls URL.createObjectURL during import for its worker
setup, which doesn't exist in jsdom. Add the mock to test setup.

https://claude.ai/code/session_01Ffqq7YPCJE28uUFR88eK7C

* Run go fmt on unformatted files

https://claude.ai/code/session_01Ffqq7YPCJE28uUFR88eK7C

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-15 23:06:20 -07:00
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
a83f4feddb Longer test timeout for broker test 2025-05-22 14:37:57 -07:00
Daniel Pupius
bc3104f59c go fmt 2025-05-22 14:35:02 -07:00
Daniel Pupius
61a83bafca Better retry and reconnection logic 2025-05-21 14:35:10 -07:00
Daniel Pupius
0feb2591ef Remove stats listener since it is noisy in prod 2025-05-19 11:00:10 -07:00
Daniel Pupius
84f8cdfe5c MQTT SetOrderMatters(false) 2025-05-04 16:12:32 -07:00
Daniel Pupius
3ce8889786 Debugging prod failures 2025-05-04 10:15:42 -07:00
Daniel Pupius
4f6ee2ffde go fmt 2025-05-02 13:50:28 -07:00
Daniel Pupius
23deefe061 More fixes for CI/CD 2025-05-02 13:20:57 -07:00
Daniel Pupius
c7abbbd4be Allow 1.5s to drain cached packets 2025-04-26 11:40:00 -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
2d61d369b0 Update MQTT packet handling to use protobuf structures directly
- Refactored decoder to use protobuf-defined Packet, TopicInfo, and Data structures
- Updated MQTT client and broker to work with protobuf structures directly
- Improved logging to properly serialize protobuf messages for structured output
- Optimized .logista.yaml template for cleaner, more compact log display

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-04-22 10:30:39 -07:00
Daniel Pupius
0784ccb958 Simplify packet construction 2025-04-21 22:34:49 -07:00
Daniel Pupius
f580249162 Another checkpoint moving to proto defined packets 2025-04-21 18:27:55 -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
56a14fff61 Simplify MessageLogger to use structured logging only
- Remove file-based logging completely
- Add brief mode for concise log output
- Add full mode with complete message details
- Use structured logging fields for all information
- Keep console output option for readability
- Add intelligent summary handling for different message types
2025-04-21 11:19:53 -07:00
Daniel Pupius
3fe611e094 Update tests to inject loggers
- Add logger injection in client_test.go
- Add logger injection in broker_test.go
- Add test logger with appropriate test namespace
- Fix all tests to work with updated constructor signatures
2025-04-21 11:13:08 -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
b7cec0feff Update MessageStats to use structured logging
- Replace fmt.Println with structured logging
- Use structured fields for better filtering and analysis
- Group related data into logical clusters
- Improve readability of statistics in logs
- Keep consistent style with rest of the application
2025-04-21 11:05:01 -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
7c311b3386 Remove unnecessary Close() overrides from subscribers 2025-04-21 09:18:16 -07:00
Daniel Pupius
b52834dd8a Add BaseSubscriber to reduce duplication between subscribers 2025-04-21 09:17:05 -07:00
Daniel Pupius
ef660b2025 Consolidate display and logging functionality in MessageLogger 2025-04-21 08:52:15 -07:00
Daniel Pupius
c129be3be6 Update MessageLogger to log all packet types 2025-04-20 20:13:04 -07:00
Daniel Pupius
a4be4caa55 "Add message broker for distributing packets to multiple consumers 2025-04-20 20:08:19 -07:00
Daniel Pupius
8c52664cc5 Refactor message handling to use switch statement
- Replace if-else chain with cleaner switch statement
- Add support for "c" format messages
- Improve code structure and readability

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-04-20 19:09:37 -07:00
Daniel Pupius
4eb98b7455 Simplify MQTT package API by embedding TopicInfo
- Created Packet to combine DecodedPacket and TopicInfo
- Updated MQTT client to return Packet instead of wrapper type
- Modified main.go to use the simplified structure
- Updated tests to use the new Packet type

This change simplifies the API and reduces the cognitive load
for consumers of the MQTT package.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-04-20 19:08:01 -07:00
Daniel Pupius
879877fa53 Refactor MQTT handling into separate package
- Created new mqtt package with simple client interface
- Implemented buffered channel for decoded messages
- Updated main.go to use the new MQTT client
- Added tests for the MQTT client
- Simplified message handling to focus on 'e' and 'map' formats
- Added TODO for handling JSON format messages

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-04-20 18:11:15 -07:00