mirror of
https://github.com/zvx-echo6/meshai.git
synced 2026-08-26 17:31:34 +00:00
feat(broadcast): fit all mesh message formats to the packet budget (#8)
Tighten broadcast formats to fit 140 chars with critical info preserved: traffic (directions/milepost never abbreviated, narrative trimmed from end), nws hazard wording tightened (towns already path-sampled), fires (drop ID line + ** + discovery time), avy (advice -> first sentence), satpass/quake safety cap. Fire digest broadcast disabled by default. All budget-aware via the shared max_chars. Co-authored-by: Matt Johnson <mj@k7zvx.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7c15fa3f09
commit
6bc57709a2
19 changed files with 546 additions and 116 deletions
|
|
@ -194,3 +194,49 @@ def test_missing_event_id_returns_none(adapter):
|
|||
def test_does_not_raise_on_corrupted_dict(adapter):
|
||||
"""Corrupted dict returns None without raising."""
|
||||
assert adapter.to_event({"garbage": True}) is None
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Central avy_handler._render (mesh broadcast wire) -- budget-fit format.
|
||||
# advice -> FIRST SENTENCE only; zone/level/source kept FULL; fits 140.
|
||||
# ============================================================================
|
||||
|
||||
from meshai.central.avy_handler import _render as _avy_render
|
||||
|
||||
|
||||
def test_avy_render_advice_first_sentence_only():
|
||||
wire = _avy_render(
|
||||
danger_level=4, danger_name="High",
|
||||
zone_name="Western Mountains",
|
||||
center_id="SNFAC",
|
||||
travel=("Avoid all avalanche terrain today. Natural and human-triggered "
|
||||
"avalanches are likely on steep slopes."),
|
||||
)
|
||||
# first sentence retained (with its period), the rest dropped
|
||||
assert "Avoid all avalanche terrain today." in wire
|
||||
assert "Natural and human-triggered" not in wire
|
||||
# zone / level / source kept FULL (never abbreviated)
|
||||
assert "Western Mountains" in wire
|
||||
assert "High (4)" in wire
|
||||
assert "SNFAC" in wire
|
||||
|
||||
|
||||
def test_avy_render_worst_case_fits_140():
|
||||
# Long multi-sentence advice paragraph -- only the first sentence is kept,
|
||||
# which lets the full zone / level / source survive under the 140 budget.
|
||||
wire = _avy_render(
|
||||
danger_level=5, danger_name="Extreme",
|
||||
zone_name="Western Mountains",
|
||||
center_id="Sawtooth Avalanche Center",
|
||||
travel=("Avoid all avalanche terrain today! Very dangerous conditions "
|
||||
"exist across all elevations and aspects with widespread natural "
|
||||
"avalanche activity likely through the afternoon and overnight."),
|
||||
)
|
||||
assert len(wire) <= 140, f"{len(wire)} chars:\n{wire!r}"
|
||||
# zone, level, source, and the first-sentence advice all present
|
||||
assert "Western Mountains" in wire
|
||||
assert "Extreme (5)" in wire
|
||||
assert "Sawtooth Avalanche Center" in wire
|
||||
assert "Avoid all avalanche terrain today!" in wire
|
||||
# first sentence terminates at the '!' -> the rest is gone
|
||||
assert "Very dangerous conditions" not in wire
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue