Repository navigation
feat: record each output-device drive and its result (TRA-1314) - #780
Draft
mikestankavich wants to merge 4 commits into
Draft
mikestankavich wants to merge 4 commits into
mikestankavich wants to merge 4 commits into
Conversation
alarm_events says a rule fired for a read. It does not say which devices were driven or whether the drive reached them, so a drive to an offline reader looks the same as one that sounded the horn. output_drives is the delivery record: device, edge, cause, ok/error with the error text, and latency. InsertAlarmEvent now returns the row id so the drives that deliver an alarm can name it. Refs: TRA-1314 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Evaluate now writes the alarm_events row before driving, so each ON names the fire it delivered, then records one output_drives row per drive: the fire's ONs (cause alarm), a held presence output's refreshes (refresh) and the age-out OFF (age_out), which had no record at all. A fire whose every drive failed is logged as a warning and counted in geofence_alarms_undelivered_total, so a drive to an offline reader no longer reads as a working alarm. A failed alarm or drive-row write never stops or delays a drive. Refs: TRA-1314 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The manual actions drive the same devices a geofence fire does, and commissioning proves a horn works with the test action. Each now leaves an output_drives row (cause test, reset or delete), failures included, so that proof no longer needs SSH to the reader's own log. Refs: TRA-1314 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A CS463 GPO drive goes through readercontrol's fire-and-forget Notify, and a Shelly over MQTT is a bare publish: success means the broker took the message, not that the device acted. A powered-off reader therefore recorded result=ok. An mqtt-transport drive that publishes cleanly is now result=sent; only an http device's drive can be ok. geofence_alarms_fired_total's help now says detected, not sounded. Refs: TRA-1314 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft: held out of 1.6 by the planning session. One question on the ticket is still open (below).
Adds
output_drives, one row for each output-device drive. Each row records which device was driven, on or off, why, and whether it worked. Until nowalarm_eventsonly said that a rule fired for a read. A drive to an offline reader left a row that looked like a working alarm, one row covered every device at the location, and presence age-out OFFs left nothing at all.What changed
output_drives: device, alarm id (set on the ON a fire sends, otherwise null), edge, cause, result (ok/sent/error) with error text, latency and drive time. It has RLS likealarm_events.alarm,refresh,age_out,test,resetordelete.geofence_alarms_undelivered_total.ListOutputDrivesreturns one device's drives, newest first. That is the per-output query TRA-945 needs.Decisions to review
alarm_eventsstays the detection record; the drive rows are the delivery record. The ticket offered "writealarm_eventsonly on success". TRA-1303 decided on 2026-11-05 to write the alarm and its notification trigger in the scan transaction, before any drive, so that option is closed.geofence_alarms_fired_total's help text now says detected.sentinstead ofokfor MQTT transports. A CS463 GPO drive goes throughreadercontrol.Client.Notify, which is fire-and-forget, and a Shelly over MQTT is a bare publish. A powered-off reader still lets the publish succeed. So those drives recordsent, and only an HTTP device's drive can beok.engine.go,presence.goandalarm_events.go. Both of them and this PR write the alarm before driving, so the two designs agree. Whichever lands second rebases.Coverage against the ticket
result=error: done for HTTP failures and broker-publish failures. Not done for a CS463 GPO on a live broker, which recordssent. That is the open question.ListOutputDrives).Known minor gaps (not fixed here)
output_driveshas no retention policy. A continuously held presence output writes about 8,640 refresh rows a day.geofence_output_drives_total.driven_atmixes the read's receive time with wall-clock time for age-out.WithoutCancellets one message's processing run past its 30 s deadline.Testing
just validatepasses.go test -race ./internal/geofencepasses.test/sentfor both the ON and the OFF.sent, noterror(expected, pending the question).Refs TRA-1314
🤖 Generated with Claude Code