Katkat

Track Repeated Approval Alerts and Safely Update Alert Levels

ZipHQSoftware Engineer · Onsite

Last updated

Design cached alert counts and rejection decisions with explicit thresholds, level-update semantics, duplicate handling, and recoverable state.

Extend a work-order approval flow with a cache that tracks repeated alerts and causes rejection when an alert-count rule is met. Then support updates to an alert's level.

Requirements and Constraints

The task supplies the repeated-alert rejection behavior and the alert-level update extension, but not the cache key, count threshold, time window, level definitions, or retroactive effect of a level change. Clarify these rules before implementing a specific policy. Explain a design that keeps cached state, alert updates, and approval decisions consistent.

Part 1 — Count Alerts and Apply the Rejection Rule

Describe the stored data and the operation that records an alert and determines whether a work order should be rejected.

What This Part Should Cover

  • The entity being counted, the cache key, and the definition of a qualifying alert occurrence.
  • The configured threshold and any expiration or time-window rule.
  • Duplicate delivery, concurrent updates, and the relationship between cached state and authoritative state.

Part 2 — Update Alert Level

Describe how an alert's level can change and how that update affects counts and decisions.

What This Part Should Cover

  • Whether level describes an alert instance, an alert category, or the approval policy.
  • Whether changing the level modifies historical contributions or only future decisions.
  • Cache invalidation or versioning, safe recomputation where needed, and auditability of earlier decisions.

Hints

Hint 1

An update may change membership, not just a label: If only some alert levels count toward rejection, changing a level can move an existing alert into or out of the counted set. Decide whether that policy is retroactive before adjusting a counter.

Follow-up questions

  • What happens if the same alert is delivered twice?
  • How would you update the count if an alert's level changes from a counted level to an uncounted level under a retroactive policy?
  • Could cache eviction cause a work order to be approved incorrectly, and how would you prevent that?