Lightning cluster archive #132
Labels
No labels
area:ai
area:ci-cd
area:notifications
area:observability
area:public-pages
backlog
bug
duplicate
enhancement
help wanted
invalid
question
type:decision
type:feature
type:infra
type:maintenance
type:security
v1.0.1
v1.1.0
v1.2.0
v1.3.0
v2.0.0
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
rbrooks/WeatherBot#132
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent: #22.
Lightning persists nothing today.
parse_placefileresults live in_LIGHTNING_CACHE, an in-memory dict with a 60-second TTL (app/services/lightning.py:57,62), capped at_MAX_CLUSTERS = 500(:54). Proximity alerts dispatch a syntheticNWSAlert(lightning_alerts.py:63-89) that is never written tosent_alerts; the only durable trace isLocation.lightning_last_seen_at/lightning_last_alerted_at.Decision taken: archive full cluster data, not just proximity events, so the Explorer can replay strike activity on an event timeline.
Sizing (estimated — confirm against real data before locking retention)
poll_lightningruns every 2 minutes (config.py:156) = 720 polls/day, up to 500 clusters each. Saturated that is ~54 MB/day, but saturation never holds. At a ~3% annual duty cycle and ~200 clusters when active: ~230 MB/year per fetch region before dedup. Regions are metro-sized, since_LIGHTNING_CACHEkeys on rounded lat/lon and co-located locations share one.Clusters repeat heavily across consecutive polls — the feed carries recent strikes with an
age_minfield, so the same strike appears in many successive fetches. Dedup should cut this 5–10x, landing around 25–50 MB/year/region, with a bad-season tail into the low GB if dedup underperforms.For contrast, proximity-events-only would be ~30 KB/location/year. The full archive is roughly three orders of magnitude larger, which is affordable but not free.
Tasks
LIGHTNING_ON_PUBLIC_PAGES(default off), because the data is licensed to the subscriber. A durable archive is a stronger posture than a live overlay. Record the finding on this issue. If the terms forbid retention, fall back to persisting only edge-triggered proximity events and note that here.Done — PR #156 merged to
mainas12d47dd(CI run #5086 green: ruff,alembic upgrade headon Postgres, both test tiers,pip-audit). Branchfeat/lightning-archivedeleted. This closes the capture phase of the v2.0.0 epic (#22): #129, #130, #131, #132 are all in.What shipped
lightning_clusterstable (migration0032) with a UNIQUEdedup_keybuilt from the cluster's own coordinates and time at ~11 m resolution — deliberately not rounded to the ~1.1 km granularity of the fetch cache, which would have discarded genuinely distinct clusters._process_location, so it costs no extra upstream requests against the paid subscriber feed.RETENTION_LIGHTNING_CLUSTERS_DAYS(default 90) andLIGHTNING_ARCHIVE_ENABLED(default true, no-op unlessLIGHTNING_PLACEFILE_URLis set).Task list status
Carried forward
The sizing on this issue (~25–50 MB/year/region) is arithmetic, not measurement — as is #130's ~165 MB/location/year. Production started capturing snapshots, radar frames and lightning at ~03:50 UTC today, so real row counts and table sizes now exist. #133 (unified 13-month horizon) will query prod for measured figures and set the horizon against those rather than the estimates. Numbers will be posted back here when measured.
Known coverage limit: only locations with
lightning_alert_radius_miset are polled, so archive coverage follows proximity-alert opt-in. Widening it means fetching for every location and multiplying requests against a paid feed — a deliberate deferral, same shape as the #129 gap but with a real cost attached.Measurement attempt — not yet possible, and why
Following up on the open "instrument real row counts and bytes" task. Prod queried at 2026-07-28 14:30 UTC, ~3 minutes after the archive deployed (
12d47dd, migration0032applied). Full measurement set for every table is on #133 (comment).lightning_clusters: 0 rows. The estimate here (~25–50 MB/year/region) therefore remains unvalidated — I have no measured figure to replace it with.That is expected rather than broken. Verified live:
poll_lightning_jobis scheduled and executing (interval[0:02:00], ran successfully at 14:29:48 UTC).media:lightning_placefilefreshness reportssuccess=True failure_count=0on each tick.archive_clusters()is on the fetch path before the radius filter, at lightning_alerts.py:155.So the archive is wired and running; the feed simply has no strikes near the opted-in location right now.
archive_clustersreturns 0 without logging on an empty batch, so silence here is the no-lightning case, not a failure.Coverage is narrower than the estimate assumed. Only 1 of 5 locations has
lightning_alert_radius_miset, so the archive currently covers a single fetch region — the known coverage limit recorded when this shipped, now with a number on it. Any measured MB/year/region figure will come from that one region until more locations opt in.Re-measure after a convective season with actual strikes in range. Until then the 25–50 MB/year/region figure should keep its "arithmetic, not measurement" caveat, and #133 is proceeding on structural work rather than on a sizing that does not exist yet —
lightning_clusterskeeps its own 90-day override, deliberately outside the unified horizon.