Skip to content

feat(events): add notification priority levels (#131)#148

Merged
Abd-Standard merged 1 commit into
Core-Foundry:mainfrom
zeroknowledge0x:feat/issue-131-notification-priority
Jun 22, 2026
Merged

feat(events): add notification priority levels (#131)#148
Abd-Standard merged 1 commit into
Core-Foundry:mainfrom
zeroknowledge0x:feat/issue-131-notification-priority

Conversation

@zeroknowledge0x

Copy link
Copy Markdown
Contributor

Closes #131

Summary

Adds a NotificationPriority enum (Low / Medium / High / Critical) as a trailing topic on every emitted event alongside the existing NotificationCategory. Off-chain consumers (alerting, dashboards, paging) can now route notifications by priority — or page on Critical (admin transfer, authorization failure) without decoding the payload.

Why a trailing topic

Soroban events are positional — the topic at the last index is what consumers read as the most recent routing signal. By appending priority after category, existing listeners keyed off the event name or category keep working unchanged (the extra trailing topic is simply ignored). New consumers can opt in to priority-based routing.

Semantic priority mapping

Event Priority Rationale
AutoshareCreated, AutoshareUpdated Medium Operator should track
GroupActivated, GroupDeactivated Low Routine lifecycle
ContractPaused, ContractUnpaused High Operator review required
AdminTransferred, AuthorizationFailure Critical Funds/security — immediate attention

Backward compatibility

  • All 105 existing tests pass without modification of their category assertions.
  • Helper category_of/latest_category migrated from topics.last() to topics.get(n - 2) so they keep reading the category from its (now second-to-last) position.
  • New priority_of helper added for priority assertions.
  • Backward-compat shape test verifies the category_topic remains stable.

Test evidence

test result: ok. 105 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 3.77s

Run: cargo test --workspace from contract/.

Files changed

  • contract/contracts/hello-world/src/base/events.rs — add NotificationPriority enum, append trailing #[topic] priority to every event struct (+46)
  • contract/contracts/hello-world/src/autoshare_logic.rs — set semantic priority at every publish site (+12)
  • contract/contracts/hello-world/src/tests/notification_test.rs — migrate topic helpers from topics.last()topics.get(n-2), add priority_of helper, add priority assertions (+77)
3 files changed, 126 insertions(+), 9 deletions(-)

Signed-off-by: zeroknowledge0x zeroknowledge0x@users.noreply.github.com

…ore-Foundry#131)

Add a NotificationPriority enum (Low/Medium/High/Critical) as a trailing
topic on every emitted event, alongside the existing NotificationCategory.
Off-chain consumers (alerting, dashboards, paging) can now route by
priority — or page on Critical (admin transfer, authorization failure)
without decoding the payload.

Backward compatibility: priority is added as the LAST topic. Existing
listeners keyed off category or the event name keep working unchanged.

- Add NotificationPriority contracttype enum to base/events.rs
- Append priority as trailing #[topic] on every event struct
- Update autoshare_logic.rs publish sites with semantic priority:
  * Low: GroupActivated/GroupDeactivated (routine lifecycle)
  * Medium: AutoshareCreated/AutoshareUpdated (operator awareness)
  * High: ContractPaused/ContractUnpaused (operator review)
  * Critical: AdminTransferred/AuthorizationFailure (urgent)
- Migrate topic helpers from topics.last() to topics.get(n-2) for
  category (pitfall Core-Foundry#69 prevention); add priority_of helper
- Update existing tests with priority assertions; add backward-compat
  shape test verifying category_topic index remains stable

All 105 tests pass (cargo test --workspace).

Signed-off-by: zeroknowledge0x <zeroknowledge0x@users.noreply.github.com>
@Abd-Standard Abd-Standard merged commit 51b94ca into Core-Foundry:main Jun 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Contracts] Add Notification Priority Levels

2 participants