feat: Support 2-byte and 3-byte path hash modes + fix config_validation example path #12

Merged
ppfeiffer merged 3 commits from feat/path-hash-mode-support into main 2026-03-23 12:47:23 +01:00
Owner

Summary

  • feat: MeshCore firmware supports three path hash sizes (1/2/3 bytes per node). Previously the bot always assumed 1-byte node hashes, silently misinterpreting paths when the device was configured for mode 1 or 2.
  • fix: _get_command_prefix_to_section() in config_validation.py suchte Example-Configs im Projektstamm statt im configs/-Unterverzeichnis — Ähnlichkeitsvorschläge für unbekannte Sektionen wurden dadurch nie angezeigt.
  • tests: 46 neue Unit-Tests für die path_hash_mode-Unterstützung

Changes

modules/core.py

  • Liest path_hash_mode aus self_info beim Connect und speichert als bot.path_hash_mode (default 0 = 1-byte, unverändertes Verhalten)

modules/message_handler.py

  • Neue Hilfsfunktionen _path_bytes_to_nodes() und _path_hex_to_nodes() mit konfigurierbarer Hash-Größe
  • decode_meshcore_packet(): übergibt hash_size an _process_packet_path()
  • _process_packet_path(): akzeptiert hash_size-Parameter (TRACE-Pfad-Hashes bleiben 1-byte gemäß Protokollspezifikation)
  • _update_mesh_graph_from_advert(): nutzt Geräte-hash_size für Node-Splitting
  • _store_observed_path(): nutzt Geräte-hash_size für from_prefix/to_prefix
  • _format_path_string(): akzeptiert hash_size-Parameter
  • DM-Pfadanzeige und discover_message_path: leiten hash_size aus out_path_hash_mode-Feld des Kontakts ab

modules/config_validation.py

  • _get_command_prefix_to_section() sucht Example-Configs nun zuerst in configs/, dann im Projektstamm als Fallback

tests/unit/test_path_hash_mode.py

  • 46 neue Tests für _path_bytes_to_nodes, _path_hex_to_nodes, _format_path_string, _process_packet_path, discover_message_path, _update_mesh_graph_from_advert und die path_hash_mode-Initialisierung in core.py

Test plan

  • 474/474 Tests bestehen
  • Keine Regression in bestehenden Pfad-Tests
  • 46 neue Tests für path_hash_mode-Unterstützung

🤖 Generated with Claude Code

## Summary - **feat**: MeshCore firmware supports three path hash sizes (1/2/3 bytes per node). Previously the bot always assumed 1-byte node hashes, silently misinterpreting paths when the device was configured for mode 1 or 2. - **fix**: `_get_command_prefix_to_section()` in `config_validation.py` suchte Example-Configs im Projektstamm statt im `configs/`-Unterverzeichnis — Ähnlichkeitsvorschläge für unbekannte Sektionen wurden dadurch nie angezeigt. - **tests**: 46 neue Unit-Tests für die path_hash_mode-Unterstützung ## Changes ### `modules/core.py` - Liest `path_hash_mode` aus `self_info` beim Connect und speichert als `bot.path_hash_mode` (default 0 = 1-byte, unverändertes Verhalten) ### `modules/message_handler.py` - Neue Hilfsfunktionen `_path_bytes_to_nodes()` und `_path_hex_to_nodes()` mit konfigurierbarer Hash-Größe - `decode_meshcore_packet()`: übergibt `hash_size` an `_process_packet_path()` - `_process_packet_path()`: akzeptiert `hash_size`-Parameter (TRACE-Pfad-Hashes bleiben 1-byte gemäß Protokollspezifikation) - `_update_mesh_graph_from_advert()`: nutzt Geräte-`hash_size` für Node-Splitting - `_store_observed_path()`: nutzt Geräte-`hash_size` für `from_prefix`/`to_prefix` - `_format_path_string()`: akzeptiert `hash_size`-Parameter - DM-Pfadanzeige und `discover_message_path`: leiten `hash_size` aus `out_path_hash_mode`-Feld des Kontakts ab ### `modules/config_validation.py` - `_get_command_prefix_to_section()` sucht Example-Configs nun zuerst in `configs/`, dann im Projektstamm als Fallback ### `tests/unit/test_path_hash_mode.py` - 46 neue Tests für `_path_bytes_to_nodes`, `_path_hex_to_nodes`, `_format_path_string`, `_process_packet_path`, `discover_message_path`, `_update_mesh_graph_from_advert` und die `path_hash_mode`-Initialisierung in `core.py` ## Test plan - [x] 474/474 Tests bestehen - [x] Keine Regression in bestehenden Pfad-Tests - [x] 46 neue Tests für path_hash_mode-Unterstützung 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MeshCore firmware supports three path hash sizes (1/2/3 bytes per node).
Previously the bot always assumed 1-byte node hashes, silently misinterpreting
paths when the device was configured for mode 1 or 2.

Changes:
- modules/core.py: Read path_hash_mode from self_info at connect time and
  store as bot.path_hash_mode (default 0 = 1-byte, unchanged behaviour)
- modules/message_handler.py:
  - Add module-level helpers _path_bytes_to_nodes() and _path_hex_to_nodes()
    that chunk by configurable hash_size
  - decode_meshcore_packet(): pass device hash_size to _process_packet_path()
  - _process_packet_path(): accept hash_size parameter; TRACE path hashes
    remain 1-byte as per protocol spec
  - _update_mesh_graph_from_advert(): use device hash_size for node splitting
  - _store_observed_path(): use device hash_size for from_prefix/to_prefix
  - _format_path_string(): accept hash_size parameter
  - DM path display and _discover_message_path/_debug_decode_message_path:
    derive hash_size from contact's out_path_hash_mode field

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fix: _get_command_prefix_to_section sucht Example-Configs in configs/
Some checks failed
Build and Push Docker Image / build (pull_request) Failing after 1m47s
Tests / test (pull_request) Failing after 29s
b13daac655
Die Example-Konfigurationsdateien liegen im Unterverzeichnis configs/,
nicht im Projektstamm. Dadurch gab _get_command_prefix_to_section()
immer ein leeres Dict zurück und die Ähnlichkeitsvorschläge für
unbekannte Config-Sektionen funktionierten nicht.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
tests: Unit-Tests für path_hash_mode-Unterstützung (1/2/3-Byte Node-Hashes)
Some checks failed
Build and Push Docker Image / build (pull_request) Failing after 43s
Tests / test (pull_request) Failing after 25s
ba01348289
Deckt _path_bytes_to_nodes, _path_hex_to_nodes, _format_path_string,
_process_packet_path, discover_message_path, _update_mesh_graph_from_advert
sowie die path_hash_mode-Initialisierung in core.py ab (46 Tests).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ppfeiffer/meshcore-bot!12
No description provided.