meshai/work/tests/test_fire_age_gate.py

182 lines
6.9 KiB
Python
Raw Normal View History

"""Step 3 fire age-gate tests (Step 5 verification, age-gate part).
chore(central-ripout 2d-i): relocate the fire engine + renderer out of central/ (#164) Moves the last two live files out of the retired-Central folder. central/ is now EMPTY and deleted entirely (incl. __init__.py). - fire-fusion engine (ingest_hotspot_pixel + the growth/cluster/spotting engine) → env/fire_fusion.py, next to its sole consumer env/firms.py. - wildfire text renderer (_render + its live helpers) → env/fire_render.py. THE COUPLING RESOLVED: firms_handler._handle_pass_boundary had a LAZY import inside a function body — `from meshai.central.wfigs_handler import _render` — sitting on the live FIRMS fire-growth path. It is now a normal top-of-file import (`from meshai.env.fire_render import _render`), visible and greppable. PURE MOVE — no behavior change: - The parity oracle (test_fire_refactor.py) PASSES UNCHANGED (only its import paths updated) — proving the fire wire output is byte-for-byte identical before and after. Fire alerts say exactly what they said. - handle_firms / handle_wfigs (dead entrypoints, only caller was the deleted consumer.py) were KEPT and moved rather than dropped — the wording-cleanup PR removes them deliberately. "When unsure, keep." - fire_render.py's geo-helper imports still point at central_normalizer — that file's split is a SEPARATE PR; carried the imports along, did not touch it. Consumers + test import paths rewired. Full suite: 2059 passed, 0 failed. Co-authored-by: Matt Johnson <mj@k7zvx.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 16:31:48 -06:00
Targets `meshai.env.fire_render._fire_too_old_to_announce` and the
handler's "New"-path suppression behaviour.
The gate exists because MeshAI broadcast a 6-week-old, already-closed fire
(OTR 11, declared_at=2026-05-06, ~45d old) to the live mesh as "New". The
gate keys on the fire's OWN declared_at age, not event recency.
Knob: ("wfigs","max_declare_age_seconds"), default 1209600 (14d), 0 = off.
The helper re-reads the knob each call (cache-backed, GUI-invalidated) and
FAILS OPEN (announces) when disabled or declared_at is None.
The autouse conftest fixture seeds adapter_config from the defaults
registry, so max_declare_age_seconds starts at its 14d default. Tests that
need a different value UPDATE the row + invalidate_cache().
"""
from __future__ import annotations
import time
import pytest
chore(central-ripout 2d-i): relocate the fire engine + renderer out of central/ (#164) Moves the last two live files out of the retired-Central folder. central/ is now EMPTY and deleted entirely (incl. __init__.py). - fire-fusion engine (ingest_hotspot_pixel + the growth/cluster/spotting engine) → env/fire_fusion.py, next to its sole consumer env/firms.py. - wildfire text renderer (_render + its live helpers) → env/fire_render.py. THE COUPLING RESOLVED: firms_handler._handle_pass_boundary had a LAZY import inside a function body — `from meshai.central.wfigs_handler import _render` — sitting on the live FIRMS fire-growth path. It is now a normal top-of-file import (`from meshai.env.fire_render import _render`), visible and greppable. PURE MOVE — no behavior change: - The parity oracle (test_fire_refactor.py) PASSES UNCHANGED (only its import paths updated) — proving the fire wire output is byte-for-byte identical before and after. Fire alerts say exactly what they said. - handle_firms / handle_wfigs (dead entrypoints, only caller was the deleted consumer.py) were KEPT and moved rather than dropped — the wording-cleanup PR removes them deliberately. "When unsure, keep." - fire_render.py's geo-helper imports still point at central_normalizer — that file's split is a SEPARATE PR; carried the imports along, did not touch it. Consumers + test import paths rewired. Full suite: 2059 passed, 0 failed. Co-authored-by: Matt Johnson <mj@k7zvx.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 16:31:48 -06:00
from meshai.env.fire_render import _fire_too_old_to_announce
_14D = 14 * 86400
_45D = 45 * 86400
_5D = 5 * 86400
def _set_knob(seconds: int):
"""Override max_declare_age_seconds in adapter_config + drop the cache so
the helper re-reads it on its next call."""
from meshai.persistence import get_db
from meshai.adapter_config import invalidate_cache
get_db().execute(
"UPDATE adapter_config SET value_json=? "
"WHERE adapter='wfigs' AND key='max_declare_age_seconds'",
(str(int(seconds)),),
)
invalidate_cache()
# ---------------------------------------------------------------------------
# Helper-level: the five required cases.
# ---------------------------------------------------------------------------
def test_declared_at_none_fails_open():
"""declared_at_epoch=None -> announce (fail-open). Default 14d knob."""
now = int(time.time())
assert _fire_too_old_to_announce(None, now) is False
def test_old_fire_suppressed_default_knob():
"""~45 days old + default 14d knob -> suppress (models OTR 11)."""
now = int(time.time())
declared = now - _45D
assert _fire_too_old_to_announce(declared, now) is True
def test_recent_fire_announces():
"""~5 days old -> announce (well under the 14d default)."""
now = int(time.time())
declared = now - _5D
assert _fire_too_old_to_announce(declared, now) is False
def test_knob_zero_disables_gate():
"""knob=0 -> gate disabled, even an ancient fire announces (fail-open)."""
_set_knob(0)
now = int(time.time())
declared = now - _45D
assert _fire_too_old_to_announce(declared, now) is False
def test_boundary_exactly_14d_is_suppressed():
"""Boundary: a fire declared exactly the knob age ago -> suppressed (>=)."""
now = int(time.time())
declared = now - _14D # exactly 14 days
assert _fire_too_old_to_announce(declared, now) is True
def test_boundary_one_second_under_14d_announces():
"""Just under the boundary (14d - 1s) -> announce (strict >= cutoff)."""
now = int(time.time())
declared = now - _14D + 1
assert _fire_too_old_to_announce(declared, now) is False
def test_custom_knob_respected():
"""A custom (non-default) knob value is honoured by the helper."""
_set_knob(_5D) # 5-day gate
now = int(time.time())
assert _fire_too_old_to_announce(now - 6 * 86400, now) is True # older than 5d
assert _fire_too_old_to_announce(now - 4 * 86400, now) is False # younger than 5d
# ---------------------------------------------------------------------------
chore(central-ripout 2d-ii): remove dead fire scraps (NOT the 'rewrite' — there wasn't one) (#166) * chore(fire-ripout 2dii-a): remove dead wildfire_growth cutover path + handle_firms wildfire_growth events are always fully precomposed (env/firms.py sets _meshai_precomposed=True + title=<wire from _render()>) and the category is not in cutover.NATIVE_ALWAYS_DECIDE, so the registered fire formatter could never be reached live via compose_mesh_message for this category -- the precomposed-title bypass always won first. Removes the dead is_cutover("wildfire_growth") NEW-PATH branch in fire_fusion._handle_pass_boundary (kept the live legacy leg that calls _render unconditionally) and the now-unreachable wildfire_growth formatter registration in notifications/formatters/__init__.py. Also removes handle_firms, the dead Central NATS-envelope entrypoint (zero live production callers -- Central's consumer that drove it is gone), plus its envelope-specific filtering helpers (_confidence_passes, _in_bbox, _coerce_severity, _log_event, FIRMS_CONFIDENCE_FLOOR/FRP_FLOOR/BBOX_OPTIONAL) that had no live callers left. The shared, LIVE fusion core (_ingest_pixel_core, attribution, clustering, growth/spotting/halt) and _parse_acq_epoch are unaffected -- still the engine behind the native ingest_hotspot_pixel entrypoint. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore(fire-ripout 2dii-b): remove dead handle_wfigs entrypoint handle_wfigs (the dead Central NATS-envelope entrypoint) had zero live production callers -- Central's consumer that drove it is gone. The LIVE WFIGS path is env/fires.py (native adapter) -> env/store.py::_emit_event, forced onto gating.fire.decide + the shared fire formatter via cutover.NATIVE_ALWAYS_DECIDE, independent of this dead handler. Removes handle_wfigs and its private-only helpers (_coerce_severity, _log_event, _log_event_returning_id) that had no callers left. _render remains -- it is called directly by env.fire_fusion._handle_pass_boundary on the FIRMS wildfire_growth path, and is used as a byte-identity oracle by tests against the shared, live fire formatter. _build_canonical, _attach_commit_handles, _fire_too_old_to_announce, _now, _cleanup_stale_fires and WFIGS_BROADCAST_COOLDOWN_S are kept -- each has its own direct test coverage independent of handle_wfigs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test(fire-ripout 2dii-c): rewire fire tests off the deleted dead entrypoints handle_firms and handle_wfigs (both removed in the prior two commits) were used throughout this test suite purely as convenient DRIVERS for live logic (pixel attribution/clustering/growth/spotting/halt fusion; the WFIGS New/Update/cooldown/closed decider). Per-file disposition: Rewired to drive the LIVE native entrypoint directly (no behavior change -- same underlying _ingest_pixel_core / gating.fire.decide engines): - test_fire_tracker_phase1/2/3.py: handle_firms -> ingest_hotspot_pixel - test_firms_refactor.py: handle_firms driver helpers -> ingest_hotspot_pixel; dropped the dead wildfire_growth cutover test + the fully-redundant TestNotCutoverLegacyVerbatim class (already covered by test_firms_native_fusion.py's TestIngestGrowth/Spotting/Halt against the live entrypoint); wildfire_growth formatter registration test now asserts None (matches source change). - test_wfigs_handler.py: handle_wfigs -> _render (the live WFIGS renderer) called directly, for the anchor-priority + missing-acres cases that exercise shared/live code (_location_anchor). - test_fire_refactor.py: handle_wfigs -> gating.fire.decide() driven directly, with state written the same unconditional shape the live native path uses; TestGateSequenceParity trimmed to focus on the tombstone/closed lifecycle step (not covered by test_fire_native_growth.py's native-adapter New/Update/cooldown coverage). - test_tombstone_broadcast.py, test_fire_age_gate.py: handle_wfigs -> gating.fire.decide() driven directly; same assertions, off the dead path. Deleted as pure dead-entrypoint contract testing with no live equivalent: - test_firms_native_fusion.py::TestCentralPathUnchanged (2 tests) -- existed only to guard handle_firms's own envelope parsing. - test_firms_handler.py: confidence/FRP/bbox filtering, missing-coords, non-firms-adapter guard, event_log accounting (all handle_firms-specific; the native adapter filters upstream in a different code path). Kept + rewired: the shared _ingest_pixel_core dedup behavior and _parse_acq_epoch's int/short acq_time parsing (both genuinely live/shared). - test_wfigs_handler.py: envelope field-extraction (acres-fallback chain, IA-placeholder-as-name), tombstone/perimeter subject -> event_log, New/Update/cooldown decision + audit-row wiring (all redundant with tests/test_fire_native_growth.py's coverage of gating.fire.decide() through the real native adapter). - test_tombstone_broadcast.py::test_commit_callback_flips_handled -- asserted handle_wfigs's own event_log-row flip on commit, a Central-only concept the native path never used. - test_tail_followups.py::test_wfigs_tombstone_stamps_column -- asserted handle_wfigs's own inline tombstoned_at UPDATE; no live producer emits _kind=wfigs_tombstone today, so nothing in the live system stamps it. Both live renderers stay covered: fire_format (wildfire_declared/incident, via test_fire_refactor.py + test_fire_native_growth.py, untouched) and _render (wildfire_growth via FIRMS, via test_fire_tracker_phase2.py + test_firms_native_fusion.py's TestIngestGrowth, both driving the live ingest_hotspot_pixel entrypoint). Collection: 2010 -> 1974 tests (net -36: dead-only tests deleted, live behavior rewired 1:1 or consolidated onto already-existing native-path coverage). Full suite: 1974 passed, 0 failed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Matt Johnson <mj@k7zvx.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 22:11:00 -06:00
# Decider-path: New is suppressed, Update still emits.
#
chore(central-ripout 2d-ii): remove dead fire scraps (NOT the 'rewrite' — there wasn't one) (#166) * chore(fire-ripout 2dii-a): remove dead wildfire_growth cutover path + handle_firms wildfire_growth events are always fully precomposed (env/firms.py sets _meshai_precomposed=True + title=<wire from _render()>) and the category is not in cutover.NATIVE_ALWAYS_DECIDE, so the registered fire formatter could never be reached live via compose_mesh_message for this category -- the precomposed-title bypass always won first. Removes the dead is_cutover("wildfire_growth") NEW-PATH branch in fire_fusion._handle_pass_boundary (kept the live legacy leg that calls _render unconditionally) and the now-unreachable wildfire_growth formatter registration in notifications/formatters/__init__.py. Also removes handle_firms, the dead Central NATS-envelope entrypoint (zero live production callers -- Central's consumer that drove it is gone), plus its envelope-specific filtering helpers (_confidence_passes, _in_bbox, _coerce_severity, _log_event, FIRMS_CONFIDENCE_FLOOR/FRP_FLOOR/BBOX_OPTIONAL) that had no live callers left. The shared, LIVE fusion core (_ingest_pixel_core, attribution, clustering, growth/spotting/halt) and _parse_acq_epoch are unaffected -- still the engine behind the native ingest_hotspot_pixel entrypoint. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore(fire-ripout 2dii-b): remove dead handle_wfigs entrypoint handle_wfigs (the dead Central NATS-envelope entrypoint) had zero live production callers -- Central's consumer that drove it is gone. The LIVE WFIGS path is env/fires.py (native adapter) -> env/store.py::_emit_event, forced onto gating.fire.decide + the shared fire formatter via cutover.NATIVE_ALWAYS_DECIDE, independent of this dead handler. Removes handle_wfigs and its private-only helpers (_coerce_severity, _log_event, _log_event_returning_id) that had no callers left. _render remains -- it is called directly by env.fire_fusion._handle_pass_boundary on the FIRMS wildfire_growth path, and is used as a byte-identity oracle by tests against the shared, live fire formatter. _build_canonical, _attach_commit_handles, _fire_too_old_to_announce, _now, _cleanup_stale_fires and WFIGS_BROADCAST_COOLDOWN_S are kept -- each has its own direct test coverage independent of handle_wfigs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test(fire-ripout 2dii-c): rewire fire tests off the deleted dead entrypoints handle_firms and handle_wfigs (both removed in the prior two commits) were used throughout this test suite purely as convenient DRIVERS for live logic (pixel attribution/clustering/growth/spotting/halt fusion; the WFIGS New/Update/cooldown/closed decider). Per-file disposition: Rewired to drive the LIVE native entrypoint directly (no behavior change -- same underlying _ingest_pixel_core / gating.fire.decide engines): - test_fire_tracker_phase1/2/3.py: handle_firms -> ingest_hotspot_pixel - test_firms_refactor.py: handle_firms driver helpers -> ingest_hotspot_pixel; dropped the dead wildfire_growth cutover test + the fully-redundant TestNotCutoverLegacyVerbatim class (already covered by test_firms_native_fusion.py's TestIngestGrowth/Spotting/Halt against the live entrypoint); wildfire_growth formatter registration test now asserts None (matches source change). - test_wfigs_handler.py: handle_wfigs -> _render (the live WFIGS renderer) called directly, for the anchor-priority + missing-acres cases that exercise shared/live code (_location_anchor). - test_fire_refactor.py: handle_wfigs -> gating.fire.decide() driven directly, with state written the same unconditional shape the live native path uses; TestGateSequenceParity trimmed to focus on the tombstone/closed lifecycle step (not covered by test_fire_native_growth.py's native-adapter New/Update/cooldown coverage). - test_tombstone_broadcast.py, test_fire_age_gate.py: handle_wfigs -> gating.fire.decide() driven directly; same assertions, off the dead path. Deleted as pure dead-entrypoint contract testing with no live equivalent: - test_firms_native_fusion.py::TestCentralPathUnchanged (2 tests) -- existed only to guard handle_firms's own envelope parsing. - test_firms_handler.py: confidence/FRP/bbox filtering, missing-coords, non-firms-adapter guard, event_log accounting (all handle_firms-specific; the native adapter filters upstream in a different code path). Kept + rewired: the shared _ingest_pixel_core dedup behavior and _parse_acq_epoch's int/short acq_time parsing (both genuinely live/shared). - test_wfigs_handler.py: envelope field-extraction (acres-fallback chain, IA-placeholder-as-name), tombstone/perimeter subject -> event_log, New/Update/cooldown decision + audit-row wiring (all redundant with tests/test_fire_native_growth.py's coverage of gating.fire.decide() through the real native adapter). - test_tombstone_broadcast.py::test_commit_callback_flips_handled -- asserted handle_wfigs's own event_log-row flip on commit, a Central-only concept the native path never used. - test_tail_followups.py::test_wfigs_tombstone_stamps_column -- asserted handle_wfigs's own inline tombstoned_at UPDATE; no live producer emits _kind=wfigs_tombstone today, so nothing in the live system stamps it. Both live renderers stay covered: fire_format (wildfire_declared/incident, via test_fire_refactor.py + test_fire_native_growth.py, untouched) and _render (wildfire_growth via FIRMS, via test_fire_tracker_phase2.py + test_firms_native_fusion.py's TestIngestGrowth, both driving the live ingest_hotspot_pixel entrypoint). Collection: 2010 -> 1974 tests (net -36: dead-only tests deleted, live behavior rewired 1:1 or consolidated onto already-existing native-path coverage). Full suite: 1974 passed, 0 failed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Matt Johnson <mj@k7zvx.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 22:11:00 -06:00
# These exercise the real Case (i)/(ii)/(iii) paths in gating.fire.decide()
# (the LIVE decider) against the isolated tmp DB seeded by conftest.
#
# chore/ripout-2dii: previously drove these through handle_wfigs (the dead
# Central NATS-envelope entrypoint); that entrypoint has been removed from
# meshai.env.fire_render (zero live production callers). decide() is the
# SAME decision logic the native WFIGS adapter (env/fires.py ->
# env/store.py::_emit_event) uses live -- see tests/test_fire_native_growth.py
# for full end-to-end coverage of the age-gate through that real entrypoint.
# ---------------------------------------------------------------------------
chore(central-ripout 2d-ii): remove dead fire scraps (NOT the 'rewrite' — there wasn't one) (#166) * chore(fire-ripout 2dii-a): remove dead wildfire_growth cutover path + handle_firms wildfire_growth events are always fully precomposed (env/firms.py sets _meshai_precomposed=True + title=<wire from _render()>) and the category is not in cutover.NATIVE_ALWAYS_DECIDE, so the registered fire formatter could never be reached live via compose_mesh_message for this category -- the precomposed-title bypass always won first. Removes the dead is_cutover("wildfire_growth") NEW-PATH branch in fire_fusion._handle_pass_boundary (kept the live legacy leg that calls _render unconditionally) and the now-unreachable wildfire_growth formatter registration in notifications/formatters/__init__.py. Also removes handle_firms, the dead Central NATS-envelope entrypoint (zero live production callers -- Central's consumer that drove it is gone), plus its envelope-specific filtering helpers (_confidence_passes, _in_bbox, _coerce_severity, _log_event, FIRMS_CONFIDENCE_FLOOR/FRP_FLOOR/BBOX_OPTIONAL) that had no live callers left. The shared, LIVE fusion core (_ingest_pixel_core, attribution, clustering, growth/spotting/halt) and _parse_acq_epoch are unaffected -- still the engine behind the native ingest_hotspot_pixel entrypoint. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore(fire-ripout 2dii-b): remove dead handle_wfigs entrypoint handle_wfigs (the dead Central NATS-envelope entrypoint) had zero live production callers -- Central's consumer that drove it is gone. The LIVE WFIGS path is env/fires.py (native adapter) -> env/store.py::_emit_event, forced onto gating.fire.decide + the shared fire formatter via cutover.NATIVE_ALWAYS_DECIDE, independent of this dead handler. Removes handle_wfigs and its private-only helpers (_coerce_severity, _log_event, _log_event_returning_id) that had no callers left. _render remains -- it is called directly by env.fire_fusion._handle_pass_boundary on the FIRMS wildfire_growth path, and is used as a byte-identity oracle by tests against the shared, live fire formatter. _build_canonical, _attach_commit_handles, _fire_too_old_to_announce, _now, _cleanup_stale_fires and WFIGS_BROADCAST_COOLDOWN_S are kept -- each has its own direct test coverage independent of handle_wfigs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test(fire-ripout 2dii-c): rewire fire tests off the deleted dead entrypoints handle_firms and handle_wfigs (both removed in the prior two commits) were used throughout this test suite purely as convenient DRIVERS for live logic (pixel attribution/clustering/growth/spotting/halt fusion; the WFIGS New/Update/cooldown/closed decider). Per-file disposition: Rewired to drive the LIVE native entrypoint directly (no behavior change -- same underlying _ingest_pixel_core / gating.fire.decide engines): - test_fire_tracker_phase1/2/3.py: handle_firms -> ingest_hotspot_pixel - test_firms_refactor.py: handle_firms driver helpers -> ingest_hotspot_pixel; dropped the dead wildfire_growth cutover test + the fully-redundant TestNotCutoverLegacyVerbatim class (already covered by test_firms_native_fusion.py's TestIngestGrowth/Spotting/Halt against the live entrypoint); wildfire_growth formatter registration test now asserts None (matches source change). - test_wfigs_handler.py: handle_wfigs -> _render (the live WFIGS renderer) called directly, for the anchor-priority + missing-acres cases that exercise shared/live code (_location_anchor). - test_fire_refactor.py: handle_wfigs -> gating.fire.decide() driven directly, with state written the same unconditional shape the live native path uses; TestGateSequenceParity trimmed to focus on the tombstone/closed lifecycle step (not covered by test_fire_native_growth.py's native-adapter New/Update/cooldown coverage). - test_tombstone_broadcast.py, test_fire_age_gate.py: handle_wfigs -> gating.fire.decide() driven directly; same assertions, off the dead path. Deleted as pure dead-entrypoint contract testing with no live equivalent: - test_firms_native_fusion.py::TestCentralPathUnchanged (2 tests) -- existed only to guard handle_firms's own envelope parsing. - test_firms_handler.py: confidence/FRP/bbox filtering, missing-coords, non-firms-adapter guard, event_log accounting (all handle_firms-specific; the native adapter filters upstream in a different code path). Kept + rewired: the shared _ingest_pixel_core dedup behavior and _parse_acq_epoch's int/short acq_time parsing (both genuinely live/shared). - test_wfigs_handler.py: envelope field-extraction (acres-fallback chain, IA-placeholder-as-name), tombstone/perimeter subject -> event_log, New/Update/cooldown decision + audit-row wiring (all redundant with tests/test_fire_native_growth.py's coverage of gating.fire.decide() through the real native adapter). - test_tombstone_broadcast.py::test_commit_callback_flips_handled -- asserted handle_wfigs's own event_log-row flip on commit, a Central-only concept the native path never used. - test_tail_followups.py::test_wfigs_tombstone_stamps_column -- asserted handle_wfigs's own inline tombstoned_at UPDATE; no live producer emits _kind=wfigs_tombstone today, so nothing in the live system stamps it. Both live renderers stay covered: fire_format (wildfire_declared/incident, via test_fire_refactor.py + test_fire_native_growth.py, untouched) and _render (wildfire_growth via FIRMS, via test_fire_tracker_phase2.py + test_firms_native_fusion.py's TestIngestGrowth, both driving the live ingest_hotspot_pixel entrypoint). Collection: 2010 -> 1974 tests (net -36: dead-only tests deleted, live behavior rewired 1:1 or consolidated onto already-existing native-path coverage). Full suite: 1974 passed, 0 failed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Matt Johnson <mj@k7zvx.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 22:11:00 -06:00
def _canonical(*, irwin_id, declared_at_epoch, acres=250.0, contained=0):
return {
"_kind": "wfigs_incident",
"irwin_id": irwin_id,
"incident_name": "Old Town Road",
"incident_type": "WF",
"acres": acres,
"contained_pct": contained,
"lat": 42.93, "lon": -114.45,
"county": "Twin Falls", "state": "ID",
"declared_at_epoch": declared_at_epoch,
}
chore(central-ripout 2d-ii): remove dead fire scraps (NOT the 'rewrite' — there wasn't one) (#166) * chore(fire-ripout 2dii-a): remove dead wildfire_growth cutover path + handle_firms wildfire_growth events are always fully precomposed (env/firms.py sets _meshai_precomposed=True + title=<wire from _render()>) and the category is not in cutover.NATIVE_ALWAYS_DECIDE, so the registered fire formatter could never be reached live via compose_mesh_message for this category -- the precomposed-title bypass always won first. Removes the dead is_cutover("wildfire_growth") NEW-PATH branch in fire_fusion._handle_pass_boundary (kept the live legacy leg that calls _render unconditionally) and the now-unreachable wildfire_growth formatter registration in notifications/formatters/__init__.py. Also removes handle_firms, the dead Central NATS-envelope entrypoint (zero live production callers -- Central's consumer that drove it is gone), plus its envelope-specific filtering helpers (_confidence_passes, _in_bbox, _coerce_severity, _log_event, FIRMS_CONFIDENCE_FLOOR/FRP_FLOOR/BBOX_OPTIONAL) that had no live callers left. The shared, LIVE fusion core (_ingest_pixel_core, attribution, clustering, growth/spotting/halt) and _parse_acq_epoch are unaffected -- still the engine behind the native ingest_hotspot_pixel entrypoint. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore(fire-ripout 2dii-b): remove dead handle_wfigs entrypoint handle_wfigs (the dead Central NATS-envelope entrypoint) had zero live production callers -- Central's consumer that drove it is gone. The LIVE WFIGS path is env/fires.py (native adapter) -> env/store.py::_emit_event, forced onto gating.fire.decide + the shared fire formatter via cutover.NATIVE_ALWAYS_DECIDE, independent of this dead handler. Removes handle_wfigs and its private-only helpers (_coerce_severity, _log_event, _log_event_returning_id) that had no callers left. _render remains -- it is called directly by env.fire_fusion._handle_pass_boundary on the FIRMS wildfire_growth path, and is used as a byte-identity oracle by tests against the shared, live fire formatter. _build_canonical, _attach_commit_handles, _fire_too_old_to_announce, _now, _cleanup_stale_fires and WFIGS_BROADCAST_COOLDOWN_S are kept -- each has its own direct test coverage independent of handle_wfigs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test(fire-ripout 2dii-c): rewire fire tests off the deleted dead entrypoints handle_firms and handle_wfigs (both removed in the prior two commits) were used throughout this test suite purely as convenient DRIVERS for live logic (pixel attribution/clustering/growth/spotting/halt fusion; the WFIGS New/Update/cooldown/closed decider). Per-file disposition: Rewired to drive the LIVE native entrypoint directly (no behavior change -- same underlying _ingest_pixel_core / gating.fire.decide engines): - test_fire_tracker_phase1/2/3.py: handle_firms -> ingest_hotspot_pixel - test_firms_refactor.py: handle_firms driver helpers -> ingest_hotspot_pixel; dropped the dead wildfire_growth cutover test + the fully-redundant TestNotCutoverLegacyVerbatim class (already covered by test_firms_native_fusion.py's TestIngestGrowth/Spotting/Halt against the live entrypoint); wildfire_growth formatter registration test now asserts None (matches source change). - test_wfigs_handler.py: handle_wfigs -> _render (the live WFIGS renderer) called directly, for the anchor-priority + missing-acres cases that exercise shared/live code (_location_anchor). - test_fire_refactor.py: handle_wfigs -> gating.fire.decide() driven directly, with state written the same unconditional shape the live native path uses; TestGateSequenceParity trimmed to focus on the tombstone/closed lifecycle step (not covered by test_fire_native_growth.py's native-adapter New/Update/cooldown coverage). - test_tombstone_broadcast.py, test_fire_age_gate.py: handle_wfigs -> gating.fire.decide() driven directly; same assertions, off the dead path. Deleted as pure dead-entrypoint contract testing with no live equivalent: - test_firms_native_fusion.py::TestCentralPathUnchanged (2 tests) -- existed only to guard handle_firms's own envelope parsing. - test_firms_handler.py: confidence/FRP/bbox filtering, missing-coords, non-firms-adapter guard, event_log accounting (all handle_firms-specific; the native adapter filters upstream in a different code path). Kept + rewired: the shared _ingest_pixel_core dedup behavior and _parse_acq_epoch's int/short acq_time parsing (both genuinely live/shared). - test_wfigs_handler.py: envelope field-extraction (acres-fallback chain, IA-placeholder-as-name), tombstone/perimeter subject -> event_log, New/Update/cooldown decision + audit-row wiring (all redundant with tests/test_fire_native_growth.py's coverage of gating.fire.decide() through the real native adapter). - test_tombstone_broadcast.py::test_commit_callback_flips_handled -- asserted handle_wfigs's own event_log-row flip on commit, a Central-only concept the native path never used. - test_tail_followups.py::test_wfigs_tombstone_stamps_column -- asserted handle_wfigs's own inline tombstoned_at UPDATE; no live producer emits _kind=wfigs_tombstone today, so nothing in the live system stamps it. Both live renderers stay covered: fire_format (wildfire_declared/incident, via test_fire_refactor.py + test_fire_native_growth.py, untouched) and _render (wildfire_growth via FIRMS, via test_fire_tracker_phase2.py + test_firms_native_fusion.py's TestIngestGrowth, both driving the live ingest_hotspot_pixel entrypoint). Collection: 2010 -> 1974 tests (net -36: dead-only tests deleted, live behavior rewired 1:1 or consolidated onto already-existing native-path coverage). Full suite: 1974 passed, 0 failed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Matt Johnson <mj@k7zvx.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 22:11:00 -06:00
def test_decider_new_path_suppresses_old_fire():
"""Case (i): a brand-new fire whose declared_at is ~45d old suppresses
the 'New' broadcast (gate.broadcast is False), and the New-path category
tag is NOT applied."""
from meshai.notifications.gating.fire import decide as fire_decide
now = int(time.time())
declared = now - _45D # OTR 11 style
chore(central-ripout 2d-ii): remove dead fire scraps (NOT the 'rewrite' — there wasn't one) (#166) * chore(fire-ripout 2dii-a): remove dead wildfire_growth cutover path + handle_firms wildfire_growth events are always fully precomposed (env/firms.py sets _meshai_precomposed=True + title=<wire from _render()>) and the category is not in cutover.NATIVE_ALWAYS_DECIDE, so the registered fire formatter could never be reached live via compose_mesh_message for this category -- the precomposed-title bypass always won first. Removes the dead is_cutover("wildfire_growth") NEW-PATH branch in fire_fusion._handle_pass_boundary (kept the live legacy leg that calls _render unconditionally) and the now-unreachable wildfire_growth formatter registration in notifications/formatters/__init__.py. Also removes handle_firms, the dead Central NATS-envelope entrypoint (zero live production callers -- Central's consumer that drove it is gone), plus its envelope-specific filtering helpers (_confidence_passes, _in_bbox, _coerce_severity, _log_event, FIRMS_CONFIDENCE_FLOOR/FRP_FLOOR/BBOX_OPTIONAL) that had no live callers left. The shared, LIVE fusion core (_ingest_pixel_core, attribution, clustering, growth/spotting/halt) and _parse_acq_epoch are unaffected -- still the engine behind the native ingest_hotspot_pixel entrypoint. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore(fire-ripout 2dii-b): remove dead handle_wfigs entrypoint handle_wfigs (the dead Central NATS-envelope entrypoint) had zero live production callers -- Central's consumer that drove it is gone. The LIVE WFIGS path is env/fires.py (native adapter) -> env/store.py::_emit_event, forced onto gating.fire.decide + the shared fire formatter via cutover.NATIVE_ALWAYS_DECIDE, independent of this dead handler. Removes handle_wfigs and its private-only helpers (_coerce_severity, _log_event, _log_event_returning_id) that had no callers left. _render remains -- it is called directly by env.fire_fusion._handle_pass_boundary on the FIRMS wildfire_growth path, and is used as a byte-identity oracle by tests against the shared, live fire formatter. _build_canonical, _attach_commit_handles, _fire_too_old_to_announce, _now, _cleanup_stale_fires and WFIGS_BROADCAST_COOLDOWN_S are kept -- each has its own direct test coverage independent of handle_wfigs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test(fire-ripout 2dii-c): rewire fire tests off the deleted dead entrypoints handle_firms and handle_wfigs (both removed in the prior two commits) were used throughout this test suite purely as convenient DRIVERS for live logic (pixel attribution/clustering/growth/spotting/halt fusion; the WFIGS New/Update/cooldown/closed decider). Per-file disposition: Rewired to drive the LIVE native entrypoint directly (no behavior change -- same underlying _ingest_pixel_core / gating.fire.decide engines): - test_fire_tracker_phase1/2/3.py: handle_firms -> ingest_hotspot_pixel - test_firms_refactor.py: handle_firms driver helpers -> ingest_hotspot_pixel; dropped the dead wildfire_growth cutover test + the fully-redundant TestNotCutoverLegacyVerbatim class (already covered by test_firms_native_fusion.py's TestIngestGrowth/Spotting/Halt against the live entrypoint); wildfire_growth formatter registration test now asserts None (matches source change). - test_wfigs_handler.py: handle_wfigs -> _render (the live WFIGS renderer) called directly, for the anchor-priority + missing-acres cases that exercise shared/live code (_location_anchor). - test_fire_refactor.py: handle_wfigs -> gating.fire.decide() driven directly, with state written the same unconditional shape the live native path uses; TestGateSequenceParity trimmed to focus on the tombstone/closed lifecycle step (not covered by test_fire_native_growth.py's native-adapter New/Update/cooldown coverage). - test_tombstone_broadcast.py, test_fire_age_gate.py: handle_wfigs -> gating.fire.decide() driven directly; same assertions, off the dead path. Deleted as pure dead-entrypoint contract testing with no live equivalent: - test_firms_native_fusion.py::TestCentralPathUnchanged (2 tests) -- existed only to guard handle_firms's own envelope parsing. - test_firms_handler.py: confidence/FRP/bbox filtering, missing-coords, non-firms-adapter guard, event_log accounting (all handle_firms-specific; the native adapter filters upstream in a different code path). Kept + rewired: the shared _ingest_pixel_core dedup behavior and _parse_acq_epoch's int/short acq_time parsing (both genuinely live/shared). - test_wfigs_handler.py: envelope field-extraction (acres-fallback chain, IA-placeholder-as-name), tombstone/perimeter subject -> event_log, New/Update/cooldown decision + audit-row wiring (all redundant with tests/test_fire_native_growth.py's coverage of gating.fire.decide() through the real native adapter). - test_tombstone_broadcast.py::test_commit_callback_flips_handled -- asserted handle_wfigs's own event_log-row flip on commit, a Central-only concept the native path never used. - test_tail_followups.py::test_wfigs_tombstone_stamps_column -- asserted handle_wfigs's own inline tombstoned_at UPDATE; no live producer emits _kind=wfigs_tombstone today, so nothing in the live system stamps it. Both live renderers stay covered: fire_format (wildfire_declared/incident, via test_fire_refactor.py + test_fire_native_growth.py, untouched) and _render (wildfire_growth via FIRMS, via test_fire_tracker_phase2.py + test_firms_native_fusion.py's TestIngestGrowth, both driving the live ingest_hotspot_pixel entrypoint). Collection: 2010 -> 1974 tests (net -36: dead-only tests deleted, live behavior rewired 1:1 or consolidated onto already-existing native-path coverage). Full suite: 1974 passed, 0 failed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Matt Johnson <mj@k7zvx.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 22:11:00 -06:00
gate = fire_decide(_canonical(irwin_id="ID-OTR-11", declared_at_epoch=declared),
source="wfigs", now=float(now))
assert gate.broadcast is False, f"old fire should be silenced, got {gate!r}"
assert "category" not in gate.data_patch
def test_decider_new_path_announces_recent_fire():
"""Case (i): a recent fire (~5d) DOES broadcast 'New' and tags
wildfire_declared."""
chore(central-ripout 2d-ii): remove dead fire scraps (NOT the 'rewrite' — there wasn't one) (#166) * chore(fire-ripout 2dii-a): remove dead wildfire_growth cutover path + handle_firms wildfire_growth events are always fully precomposed (env/firms.py sets _meshai_precomposed=True + title=<wire from _render()>) and the category is not in cutover.NATIVE_ALWAYS_DECIDE, so the registered fire formatter could never be reached live via compose_mesh_message for this category -- the precomposed-title bypass always won first. Removes the dead is_cutover("wildfire_growth") NEW-PATH branch in fire_fusion._handle_pass_boundary (kept the live legacy leg that calls _render unconditionally) and the now-unreachable wildfire_growth formatter registration in notifications/formatters/__init__.py. Also removes handle_firms, the dead Central NATS-envelope entrypoint (zero live production callers -- Central's consumer that drove it is gone), plus its envelope-specific filtering helpers (_confidence_passes, _in_bbox, _coerce_severity, _log_event, FIRMS_CONFIDENCE_FLOOR/FRP_FLOOR/BBOX_OPTIONAL) that had no live callers left. The shared, LIVE fusion core (_ingest_pixel_core, attribution, clustering, growth/spotting/halt) and _parse_acq_epoch are unaffected -- still the engine behind the native ingest_hotspot_pixel entrypoint. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore(fire-ripout 2dii-b): remove dead handle_wfigs entrypoint handle_wfigs (the dead Central NATS-envelope entrypoint) had zero live production callers -- Central's consumer that drove it is gone. The LIVE WFIGS path is env/fires.py (native adapter) -> env/store.py::_emit_event, forced onto gating.fire.decide + the shared fire formatter via cutover.NATIVE_ALWAYS_DECIDE, independent of this dead handler. Removes handle_wfigs and its private-only helpers (_coerce_severity, _log_event, _log_event_returning_id) that had no callers left. _render remains -- it is called directly by env.fire_fusion._handle_pass_boundary on the FIRMS wildfire_growth path, and is used as a byte-identity oracle by tests against the shared, live fire formatter. _build_canonical, _attach_commit_handles, _fire_too_old_to_announce, _now, _cleanup_stale_fires and WFIGS_BROADCAST_COOLDOWN_S are kept -- each has its own direct test coverage independent of handle_wfigs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test(fire-ripout 2dii-c): rewire fire tests off the deleted dead entrypoints handle_firms and handle_wfigs (both removed in the prior two commits) were used throughout this test suite purely as convenient DRIVERS for live logic (pixel attribution/clustering/growth/spotting/halt fusion; the WFIGS New/Update/cooldown/closed decider). Per-file disposition: Rewired to drive the LIVE native entrypoint directly (no behavior change -- same underlying _ingest_pixel_core / gating.fire.decide engines): - test_fire_tracker_phase1/2/3.py: handle_firms -> ingest_hotspot_pixel - test_firms_refactor.py: handle_firms driver helpers -> ingest_hotspot_pixel; dropped the dead wildfire_growth cutover test + the fully-redundant TestNotCutoverLegacyVerbatim class (already covered by test_firms_native_fusion.py's TestIngestGrowth/Spotting/Halt against the live entrypoint); wildfire_growth formatter registration test now asserts None (matches source change). - test_wfigs_handler.py: handle_wfigs -> _render (the live WFIGS renderer) called directly, for the anchor-priority + missing-acres cases that exercise shared/live code (_location_anchor). - test_fire_refactor.py: handle_wfigs -> gating.fire.decide() driven directly, with state written the same unconditional shape the live native path uses; TestGateSequenceParity trimmed to focus on the tombstone/closed lifecycle step (not covered by test_fire_native_growth.py's native-adapter New/Update/cooldown coverage). - test_tombstone_broadcast.py, test_fire_age_gate.py: handle_wfigs -> gating.fire.decide() driven directly; same assertions, off the dead path. Deleted as pure dead-entrypoint contract testing with no live equivalent: - test_firms_native_fusion.py::TestCentralPathUnchanged (2 tests) -- existed only to guard handle_firms's own envelope parsing. - test_firms_handler.py: confidence/FRP/bbox filtering, missing-coords, non-firms-adapter guard, event_log accounting (all handle_firms-specific; the native adapter filters upstream in a different code path). Kept + rewired: the shared _ingest_pixel_core dedup behavior and _parse_acq_epoch's int/short acq_time parsing (both genuinely live/shared). - test_wfigs_handler.py: envelope field-extraction (acres-fallback chain, IA-placeholder-as-name), tombstone/perimeter subject -> event_log, New/Update/cooldown decision + audit-row wiring (all redundant with tests/test_fire_native_growth.py's coverage of gating.fire.decide() through the real native adapter). - test_tombstone_broadcast.py::test_commit_callback_flips_handled -- asserted handle_wfigs's own event_log-row flip on commit, a Central-only concept the native path never used. - test_tail_followups.py::test_wfigs_tombstone_stamps_column -- asserted handle_wfigs's own inline tombstoned_at UPDATE; no live producer emits _kind=wfigs_tombstone today, so nothing in the live system stamps it. Both live renderers stay covered: fire_format (wildfire_declared/incident, via test_fire_refactor.py + test_fire_native_growth.py, untouched) and _render (wildfire_growth via FIRMS, via test_fire_tracker_phase2.py + test_firms_native_fusion.py's TestIngestGrowth, both driving the live ingest_hotspot_pixel entrypoint). Collection: 2010 -> 1974 tests (net -36: dead-only tests deleted, live behavior rewired 1:1 or consolidated onto already-existing native-path coverage). Full suite: 1974 passed, 0 failed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Matt Johnson <mj@k7zvx.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 22:11:00 -06:00
from meshai.notifications.gating.fire import decide as fire_decide
now = int(time.time())
declared = now - _5D
chore(central-ripout 2d-ii): remove dead fire scraps (NOT the 'rewrite' — there wasn't one) (#166) * chore(fire-ripout 2dii-a): remove dead wildfire_growth cutover path + handle_firms wildfire_growth events are always fully precomposed (env/firms.py sets _meshai_precomposed=True + title=<wire from _render()>) and the category is not in cutover.NATIVE_ALWAYS_DECIDE, so the registered fire formatter could never be reached live via compose_mesh_message for this category -- the precomposed-title bypass always won first. Removes the dead is_cutover("wildfire_growth") NEW-PATH branch in fire_fusion._handle_pass_boundary (kept the live legacy leg that calls _render unconditionally) and the now-unreachable wildfire_growth formatter registration in notifications/formatters/__init__.py. Also removes handle_firms, the dead Central NATS-envelope entrypoint (zero live production callers -- Central's consumer that drove it is gone), plus its envelope-specific filtering helpers (_confidence_passes, _in_bbox, _coerce_severity, _log_event, FIRMS_CONFIDENCE_FLOOR/FRP_FLOOR/BBOX_OPTIONAL) that had no live callers left. The shared, LIVE fusion core (_ingest_pixel_core, attribution, clustering, growth/spotting/halt) and _parse_acq_epoch are unaffected -- still the engine behind the native ingest_hotspot_pixel entrypoint. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore(fire-ripout 2dii-b): remove dead handle_wfigs entrypoint handle_wfigs (the dead Central NATS-envelope entrypoint) had zero live production callers -- Central's consumer that drove it is gone. The LIVE WFIGS path is env/fires.py (native adapter) -> env/store.py::_emit_event, forced onto gating.fire.decide + the shared fire formatter via cutover.NATIVE_ALWAYS_DECIDE, independent of this dead handler. Removes handle_wfigs and its private-only helpers (_coerce_severity, _log_event, _log_event_returning_id) that had no callers left. _render remains -- it is called directly by env.fire_fusion._handle_pass_boundary on the FIRMS wildfire_growth path, and is used as a byte-identity oracle by tests against the shared, live fire formatter. _build_canonical, _attach_commit_handles, _fire_too_old_to_announce, _now, _cleanup_stale_fires and WFIGS_BROADCAST_COOLDOWN_S are kept -- each has its own direct test coverage independent of handle_wfigs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test(fire-ripout 2dii-c): rewire fire tests off the deleted dead entrypoints handle_firms and handle_wfigs (both removed in the prior two commits) were used throughout this test suite purely as convenient DRIVERS for live logic (pixel attribution/clustering/growth/spotting/halt fusion; the WFIGS New/Update/cooldown/closed decider). Per-file disposition: Rewired to drive the LIVE native entrypoint directly (no behavior change -- same underlying _ingest_pixel_core / gating.fire.decide engines): - test_fire_tracker_phase1/2/3.py: handle_firms -> ingest_hotspot_pixel - test_firms_refactor.py: handle_firms driver helpers -> ingest_hotspot_pixel; dropped the dead wildfire_growth cutover test + the fully-redundant TestNotCutoverLegacyVerbatim class (already covered by test_firms_native_fusion.py's TestIngestGrowth/Spotting/Halt against the live entrypoint); wildfire_growth formatter registration test now asserts None (matches source change). - test_wfigs_handler.py: handle_wfigs -> _render (the live WFIGS renderer) called directly, for the anchor-priority + missing-acres cases that exercise shared/live code (_location_anchor). - test_fire_refactor.py: handle_wfigs -> gating.fire.decide() driven directly, with state written the same unconditional shape the live native path uses; TestGateSequenceParity trimmed to focus on the tombstone/closed lifecycle step (not covered by test_fire_native_growth.py's native-adapter New/Update/cooldown coverage). - test_tombstone_broadcast.py, test_fire_age_gate.py: handle_wfigs -> gating.fire.decide() driven directly; same assertions, off the dead path. Deleted as pure dead-entrypoint contract testing with no live equivalent: - test_firms_native_fusion.py::TestCentralPathUnchanged (2 tests) -- existed only to guard handle_firms's own envelope parsing. - test_firms_handler.py: confidence/FRP/bbox filtering, missing-coords, non-firms-adapter guard, event_log accounting (all handle_firms-specific; the native adapter filters upstream in a different code path). Kept + rewired: the shared _ingest_pixel_core dedup behavior and _parse_acq_epoch's int/short acq_time parsing (both genuinely live/shared). - test_wfigs_handler.py: envelope field-extraction (acres-fallback chain, IA-placeholder-as-name), tombstone/perimeter subject -> event_log, New/Update/cooldown decision + audit-row wiring (all redundant with tests/test_fire_native_growth.py's coverage of gating.fire.decide() through the real native adapter). - test_tombstone_broadcast.py::test_commit_callback_flips_handled -- asserted handle_wfigs's own event_log-row flip on commit, a Central-only concept the native path never used. - test_tail_followups.py::test_wfigs_tombstone_stamps_column -- asserted handle_wfigs's own inline tombstoned_at UPDATE; no live producer emits _kind=wfigs_tombstone today, so nothing in the live system stamps it. Both live renderers stay covered: fire_format (wildfire_declared/incident, via test_fire_refactor.py + test_fire_native_growth.py, untouched) and _render (wildfire_growth via FIRMS, via test_fire_tracker_phase2.py + test_firms_native_fusion.py's TestIngestGrowth, both driving the live ingest_hotspot_pixel entrypoint). Collection: 2010 -> 1974 tests (net -36: dead-only tests deleted, live behavior rewired 1:1 or consolidated onto already-existing native-path coverage). Full suite: 1974 passed, 0 failed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Matt Johnson <mj@k7zvx.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 22:11:00 -06:00
gate = fire_decide(_canonical(irwin_id="ID-RECENT-1", declared_at_epoch=declared),
source="wfigs", now=float(now))
assert gate.broadcast is True
assert gate.lifecycle == "new"
assert gate.data_patch.get("category") == "wildfire_declared"
chore(central-ripout 2d-ii): remove dead fire scraps (NOT the 'rewrite' — there wasn't one) (#166) * chore(fire-ripout 2dii-a): remove dead wildfire_growth cutover path + handle_firms wildfire_growth events are always fully precomposed (env/firms.py sets _meshai_precomposed=True + title=<wire from _render()>) and the category is not in cutover.NATIVE_ALWAYS_DECIDE, so the registered fire formatter could never be reached live via compose_mesh_message for this category -- the precomposed-title bypass always won first. Removes the dead is_cutover("wildfire_growth") NEW-PATH branch in fire_fusion._handle_pass_boundary (kept the live legacy leg that calls _render unconditionally) and the now-unreachable wildfire_growth formatter registration in notifications/formatters/__init__.py. Also removes handle_firms, the dead Central NATS-envelope entrypoint (zero live production callers -- Central's consumer that drove it is gone), plus its envelope-specific filtering helpers (_confidence_passes, _in_bbox, _coerce_severity, _log_event, FIRMS_CONFIDENCE_FLOOR/FRP_FLOOR/BBOX_OPTIONAL) that had no live callers left. The shared, LIVE fusion core (_ingest_pixel_core, attribution, clustering, growth/spotting/halt) and _parse_acq_epoch are unaffected -- still the engine behind the native ingest_hotspot_pixel entrypoint. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore(fire-ripout 2dii-b): remove dead handle_wfigs entrypoint handle_wfigs (the dead Central NATS-envelope entrypoint) had zero live production callers -- Central's consumer that drove it is gone. The LIVE WFIGS path is env/fires.py (native adapter) -> env/store.py::_emit_event, forced onto gating.fire.decide + the shared fire formatter via cutover.NATIVE_ALWAYS_DECIDE, independent of this dead handler. Removes handle_wfigs and its private-only helpers (_coerce_severity, _log_event, _log_event_returning_id) that had no callers left. _render remains -- it is called directly by env.fire_fusion._handle_pass_boundary on the FIRMS wildfire_growth path, and is used as a byte-identity oracle by tests against the shared, live fire formatter. _build_canonical, _attach_commit_handles, _fire_too_old_to_announce, _now, _cleanup_stale_fires and WFIGS_BROADCAST_COOLDOWN_S are kept -- each has its own direct test coverage independent of handle_wfigs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test(fire-ripout 2dii-c): rewire fire tests off the deleted dead entrypoints handle_firms and handle_wfigs (both removed in the prior two commits) were used throughout this test suite purely as convenient DRIVERS for live logic (pixel attribution/clustering/growth/spotting/halt fusion; the WFIGS New/Update/cooldown/closed decider). Per-file disposition: Rewired to drive the LIVE native entrypoint directly (no behavior change -- same underlying _ingest_pixel_core / gating.fire.decide engines): - test_fire_tracker_phase1/2/3.py: handle_firms -> ingest_hotspot_pixel - test_firms_refactor.py: handle_firms driver helpers -> ingest_hotspot_pixel; dropped the dead wildfire_growth cutover test + the fully-redundant TestNotCutoverLegacyVerbatim class (already covered by test_firms_native_fusion.py's TestIngestGrowth/Spotting/Halt against the live entrypoint); wildfire_growth formatter registration test now asserts None (matches source change). - test_wfigs_handler.py: handle_wfigs -> _render (the live WFIGS renderer) called directly, for the anchor-priority + missing-acres cases that exercise shared/live code (_location_anchor). - test_fire_refactor.py: handle_wfigs -> gating.fire.decide() driven directly, with state written the same unconditional shape the live native path uses; TestGateSequenceParity trimmed to focus on the tombstone/closed lifecycle step (not covered by test_fire_native_growth.py's native-adapter New/Update/cooldown coverage). - test_tombstone_broadcast.py, test_fire_age_gate.py: handle_wfigs -> gating.fire.decide() driven directly; same assertions, off the dead path. Deleted as pure dead-entrypoint contract testing with no live equivalent: - test_firms_native_fusion.py::TestCentralPathUnchanged (2 tests) -- existed only to guard handle_firms's own envelope parsing. - test_firms_handler.py: confidence/FRP/bbox filtering, missing-coords, non-firms-adapter guard, event_log accounting (all handle_firms-specific; the native adapter filters upstream in a different code path). Kept + rewired: the shared _ingest_pixel_core dedup behavior and _parse_acq_epoch's int/short acq_time parsing (both genuinely live/shared). - test_wfigs_handler.py: envelope field-extraction (acres-fallback chain, IA-placeholder-as-name), tombstone/perimeter subject -> event_log, New/Update/cooldown decision + audit-row wiring (all redundant with tests/test_fire_native_growth.py's coverage of gating.fire.decide() through the real native adapter). - test_tombstone_broadcast.py::test_commit_callback_flips_handled -- asserted handle_wfigs's own event_log-row flip on commit, a Central-only concept the native path never used. - test_tail_followups.py::test_wfigs_tombstone_stamps_column -- asserted handle_wfigs's own inline tombstoned_at UPDATE; no live producer emits _kind=wfigs_tombstone today, so nothing in the live system stamps it. Both live renderers stay covered: fire_format (wildfire_declared/incident, via test_fire_refactor.py + test_fire_native_growth.py, untouched) and _render (wildfire_growth via FIRMS, via test_fire_tracker_phase2.py + test_firms_native_fusion.py's TestIngestGrowth, both driving the live ingest_hotspot_pixel entrypoint). Collection: 2010 -> 1974 tests (net -36: dead-only tests deleted, live behavior rewired 1:1 or consolidated onto already-existing native-path coverage). Full suite: 1974 passed, 0 failed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Matt Johnson <mj@k7zvx.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 22:11:00 -06:00
def test_decider_update_path_still_emits_for_old_fire():
"""An already-broadcast OLD fire that grows acreage still emits an
'Update' (Case (iii) is NOT gated -- genuine old-but-active fires keep
getting containment/acreage updates)."""
chore(central-ripout 2d-ii): remove dead fire scraps (NOT the 'rewrite' — there wasn't one) (#166) * chore(fire-ripout 2dii-a): remove dead wildfire_growth cutover path + handle_firms wildfire_growth events are always fully precomposed (env/firms.py sets _meshai_precomposed=True + title=<wire from _render()>) and the category is not in cutover.NATIVE_ALWAYS_DECIDE, so the registered fire formatter could never be reached live via compose_mesh_message for this category -- the precomposed-title bypass always won first. Removes the dead is_cutover("wildfire_growth") NEW-PATH branch in fire_fusion._handle_pass_boundary (kept the live legacy leg that calls _render unconditionally) and the now-unreachable wildfire_growth formatter registration in notifications/formatters/__init__.py. Also removes handle_firms, the dead Central NATS-envelope entrypoint (zero live production callers -- Central's consumer that drove it is gone), plus its envelope-specific filtering helpers (_confidence_passes, _in_bbox, _coerce_severity, _log_event, FIRMS_CONFIDENCE_FLOOR/FRP_FLOOR/BBOX_OPTIONAL) that had no live callers left. The shared, LIVE fusion core (_ingest_pixel_core, attribution, clustering, growth/spotting/halt) and _parse_acq_epoch are unaffected -- still the engine behind the native ingest_hotspot_pixel entrypoint. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore(fire-ripout 2dii-b): remove dead handle_wfigs entrypoint handle_wfigs (the dead Central NATS-envelope entrypoint) had zero live production callers -- Central's consumer that drove it is gone. The LIVE WFIGS path is env/fires.py (native adapter) -> env/store.py::_emit_event, forced onto gating.fire.decide + the shared fire formatter via cutover.NATIVE_ALWAYS_DECIDE, independent of this dead handler. Removes handle_wfigs and its private-only helpers (_coerce_severity, _log_event, _log_event_returning_id) that had no callers left. _render remains -- it is called directly by env.fire_fusion._handle_pass_boundary on the FIRMS wildfire_growth path, and is used as a byte-identity oracle by tests against the shared, live fire formatter. _build_canonical, _attach_commit_handles, _fire_too_old_to_announce, _now, _cleanup_stale_fires and WFIGS_BROADCAST_COOLDOWN_S are kept -- each has its own direct test coverage independent of handle_wfigs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test(fire-ripout 2dii-c): rewire fire tests off the deleted dead entrypoints handle_firms and handle_wfigs (both removed in the prior two commits) were used throughout this test suite purely as convenient DRIVERS for live logic (pixel attribution/clustering/growth/spotting/halt fusion; the WFIGS New/Update/cooldown/closed decider). Per-file disposition: Rewired to drive the LIVE native entrypoint directly (no behavior change -- same underlying _ingest_pixel_core / gating.fire.decide engines): - test_fire_tracker_phase1/2/3.py: handle_firms -> ingest_hotspot_pixel - test_firms_refactor.py: handle_firms driver helpers -> ingest_hotspot_pixel; dropped the dead wildfire_growth cutover test + the fully-redundant TestNotCutoverLegacyVerbatim class (already covered by test_firms_native_fusion.py's TestIngestGrowth/Spotting/Halt against the live entrypoint); wildfire_growth formatter registration test now asserts None (matches source change). - test_wfigs_handler.py: handle_wfigs -> _render (the live WFIGS renderer) called directly, for the anchor-priority + missing-acres cases that exercise shared/live code (_location_anchor). - test_fire_refactor.py: handle_wfigs -> gating.fire.decide() driven directly, with state written the same unconditional shape the live native path uses; TestGateSequenceParity trimmed to focus on the tombstone/closed lifecycle step (not covered by test_fire_native_growth.py's native-adapter New/Update/cooldown coverage). - test_tombstone_broadcast.py, test_fire_age_gate.py: handle_wfigs -> gating.fire.decide() driven directly; same assertions, off the dead path. Deleted as pure dead-entrypoint contract testing with no live equivalent: - test_firms_native_fusion.py::TestCentralPathUnchanged (2 tests) -- existed only to guard handle_firms's own envelope parsing. - test_firms_handler.py: confidence/FRP/bbox filtering, missing-coords, non-firms-adapter guard, event_log accounting (all handle_firms-specific; the native adapter filters upstream in a different code path). Kept + rewired: the shared _ingest_pixel_core dedup behavior and _parse_acq_epoch's int/short acq_time parsing (both genuinely live/shared). - test_wfigs_handler.py: envelope field-extraction (acres-fallback chain, IA-placeholder-as-name), tombstone/perimeter subject -> event_log, New/Update/cooldown decision + audit-row wiring (all redundant with tests/test_fire_native_growth.py's coverage of gating.fire.decide() through the real native adapter). - test_tombstone_broadcast.py::test_commit_callback_flips_handled -- asserted handle_wfigs's own event_log-row flip on commit, a Central-only concept the native path never used. - test_tail_followups.py::test_wfigs_tombstone_stamps_column -- asserted handle_wfigs's own inline tombstoned_at UPDATE; no live producer emits _kind=wfigs_tombstone today, so nothing in the live system stamps it. Both live renderers stay covered: fire_format (wildfire_declared/incident, via test_fire_refactor.py + test_fire_native_growth.py, untouched) and _render (wildfire_growth via FIRMS, via test_fire_tracker_phase2.py + test_firms_native_fusion.py's TestIngestGrowth, both driving the live ingest_hotspot_pixel entrypoint). Collection: 2010 -> 1974 tests (net -36: dead-only tests deleted, live behavior rewired 1:1 or consolidated onto already-existing native-path coverage). Full suite: 1974 passed, 0 failed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Matt Johnson <mj@k7zvx.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 22:11:00 -06:00
from meshai.notifications.gating.fire import decide as fire_decide
from meshai.persistence import get_db
now = int(time.time())
declared = now - _45D
# Pre-existing row that has already been broadcast.
get_db().execute(
"INSERT INTO fires(irwin_id, incident_name, current_acres, "
"current_contained_pct, lat, lon, declared_at, last_event_at, "
"last_broadcast_at, last_broadcast_acres, last_broadcast_contained) "
"VALUES (?,?,?,?,?,?,?,?,?,?,?)",
("ID-OLD-ACTIVE", "Old Town Road", 250.0, 0, 42.93, -114.45,
declared, now - 30000, now - 30000, 250.0, 0),
)
chore(central-ripout 2d-ii): remove dead fire scraps (NOT the 'rewrite' — there wasn't one) (#166) * chore(fire-ripout 2dii-a): remove dead wildfire_growth cutover path + handle_firms wildfire_growth events are always fully precomposed (env/firms.py sets _meshai_precomposed=True + title=<wire from _render()>) and the category is not in cutover.NATIVE_ALWAYS_DECIDE, so the registered fire formatter could never be reached live via compose_mesh_message for this category -- the precomposed-title bypass always won first. Removes the dead is_cutover("wildfire_growth") NEW-PATH branch in fire_fusion._handle_pass_boundary (kept the live legacy leg that calls _render unconditionally) and the now-unreachable wildfire_growth formatter registration in notifications/formatters/__init__.py. Also removes handle_firms, the dead Central NATS-envelope entrypoint (zero live production callers -- Central's consumer that drove it is gone), plus its envelope-specific filtering helpers (_confidence_passes, _in_bbox, _coerce_severity, _log_event, FIRMS_CONFIDENCE_FLOOR/FRP_FLOOR/BBOX_OPTIONAL) that had no live callers left. The shared, LIVE fusion core (_ingest_pixel_core, attribution, clustering, growth/spotting/halt) and _parse_acq_epoch are unaffected -- still the engine behind the native ingest_hotspot_pixel entrypoint. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore(fire-ripout 2dii-b): remove dead handle_wfigs entrypoint handle_wfigs (the dead Central NATS-envelope entrypoint) had zero live production callers -- Central's consumer that drove it is gone. The LIVE WFIGS path is env/fires.py (native adapter) -> env/store.py::_emit_event, forced onto gating.fire.decide + the shared fire formatter via cutover.NATIVE_ALWAYS_DECIDE, independent of this dead handler. Removes handle_wfigs and its private-only helpers (_coerce_severity, _log_event, _log_event_returning_id) that had no callers left. _render remains -- it is called directly by env.fire_fusion._handle_pass_boundary on the FIRMS wildfire_growth path, and is used as a byte-identity oracle by tests against the shared, live fire formatter. _build_canonical, _attach_commit_handles, _fire_too_old_to_announce, _now, _cleanup_stale_fires and WFIGS_BROADCAST_COOLDOWN_S are kept -- each has its own direct test coverage independent of handle_wfigs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test(fire-ripout 2dii-c): rewire fire tests off the deleted dead entrypoints handle_firms and handle_wfigs (both removed in the prior two commits) were used throughout this test suite purely as convenient DRIVERS for live logic (pixel attribution/clustering/growth/spotting/halt fusion; the WFIGS New/Update/cooldown/closed decider). Per-file disposition: Rewired to drive the LIVE native entrypoint directly (no behavior change -- same underlying _ingest_pixel_core / gating.fire.decide engines): - test_fire_tracker_phase1/2/3.py: handle_firms -> ingest_hotspot_pixel - test_firms_refactor.py: handle_firms driver helpers -> ingest_hotspot_pixel; dropped the dead wildfire_growth cutover test + the fully-redundant TestNotCutoverLegacyVerbatim class (already covered by test_firms_native_fusion.py's TestIngestGrowth/Spotting/Halt against the live entrypoint); wildfire_growth formatter registration test now asserts None (matches source change). - test_wfigs_handler.py: handle_wfigs -> _render (the live WFIGS renderer) called directly, for the anchor-priority + missing-acres cases that exercise shared/live code (_location_anchor). - test_fire_refactor.py: handle_wfigs -> gating.fire.decide() driven directly, with state written the same unconditional shape the live native path uses; TestGateSequenceParity trimmed to focus on the tombstone/closed lifecycle step (not covered by test_fire_native_growth.py's native-adapter New/Update/cooldown coverage). - test_tombstone_broadcast.py, test_fire_age_gate.py: handle_wfigs -> gating.fire.decide() driven directly; same assertions, off the dead path. Deleted as pure dead-entrypoint contract testing with no live equivalent: - test_firms_native_fusion.py::TestCentralPathUnchanged (2 tests) -- existed only to guard handle_firms's own envelope parsing. - test_firms_handler.py: confidence/FRP/bbox filtering, missing-coords, non-firms-adapter guard, event_log accounting (all handle_firms-specific; the native adapter filters upstream in a different code path). Kept + rewired: the shared _ingest_pixel_core dedup behavior and _parse_acq_epoch's int/short acq_time parsing (both genuinely live/shared). - test_wfigs_handler.py: envelope field-extraction (acres-fallback chain, IA-placeholder-as-name), tombstone/perimeter subject -> event_log, New/Update/cooldown decision + audit-row wiring (all redundant with tests/test_fire_native_growth.py's coverage of gating.fire.decide() through the real native adapter). - test_tombstone_broadcast.py::test_commit_callback_flips_handled -- asserted handle_wfigs's own event_log-row flip on commit, a Central-only concept the native path never used. - test_tail_followups.py::test_wfigs_tombstone_stamps_column -- asserted handle_wfigs's own inline tombstoned_at UPDATE; no live producer emits _kind=wfigs_tombstone today, so nothing in the live system stamps it. Both live renderers stay covered: fire_format (wildfire_declared/incident, via test_fire_refactor.py + test_fire_native_growth.py, untouched) and _render (wildfire_growth via FIRMS, via test_fire_tracker_phase2.py + test_firms_native_fusion.py's TestIngestGrowth, both driving the live ingest_hotspot_pixel entrypoint). Collection: 2010 -> 1974 tests (net -36: dead-only tests deleted, live behavior rewired 1:1 or consolidated onto already-existing native-path coverage). Full suite: 1974 passed, 0 failed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Matt Johnson <mj@k7zvx.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 22:11:00 -06:00
gate = fire_decide(
_canonical(irwin_id="ID-OLD-ACTIVE", declared_at_epoch=declared,
acres=900.0, contained=20),
source="wfigs", now=float(now))
assert gate.broadcast is True and gate.lifecycle == "update", \
f"old-but-active fire Update must still emit, got {gate!r}"
assert "category" not in gate.data_patch