Capture alert snapshots independent of public pages (#129) #143
No reviewers
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!143
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/history-capture-ungate"
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?
Closes #129. First implementation issue of the v2.0.0 Historical Explorer epic (#22).
Problem
nws_alert_snapshotsholds the only copy of the full official product body, geometry and hazards, and it is the raw material the Explorer reads back. It was written only from the per-channel dispatch loop in_process_single_alert(alert_processor.py:351), or when a public page already existed (:281)._process_cancelwas gated the same way.So a location with no channel subscriptions retained nothing beyond its
sent_alertsrow — event, severity, headline and times, with no product text at all. Dashboard-only locations were exactly the ones whose history was emptiest.Two corrections to how #129 was originally filed, now recorded on the issue:
Location.public_enablednever gated capture —get_or_create_public_alert_pagedoes not inspect it. It gates serving only.PUBLIC_ALERT_PAGES_ENABLEDdefaulting to false.Change
_capture_alert_snapshot, savepoint-wrapped to match the existing_ensure_public_alert_pagepattern.get_or_create_public_alert_pagevia its existingsnapshot=parameter, so the page path does not redundantly re-persist.IntegrityErroron the(location_id, lifecycle_id, content_hash)unique constraint is caught and logged at debug: overlapping poll runs can race, the row exists either way, and a traceback every poll would drown the log.Public page and token creation stay gated on
public_alert_pages_enabledexactly as before. Capture and exposure are now separate concerns.Tests
New
tests/test_history_capture.py:PublicAlertPage/PublicTokenrowsVerification
Run locally in Docker, mirroring every CI gate:
ruff check .python -m compileall appalembic upgrade headon fresh Postgres 160030Known nit
test_quiet_hours_suppress_channel_send_but_keep_dashboard_recordnow emits aRuntimeWarning(unawaited coroutine) because it passes aMagicMocksession and_capture_alert_snapshothas no early return, so it reachesbegin_nested()on the mock and the failure is swallowed fail-soft. Production behaviour is correct and covered by the new tests. The codebase already carries an identical warning intest_webhook_ssrf. Happy to fix the mock separately.🤖 Generated with Claude Code