Skip to content

test: add extensive snapshot coverage for calculator logic and update… - #532

Closed
Agbelomo wants to merge 1 commit into
ApexChainx:mainfrom
Agbelomo:Debt/issues
Closed

test: add extensive snapshot coverage for calculator logic and update…#532
Agbelomo wants to merge 1 commit into
ApexChainx:mainfrom
Agbelomo:Debt/issues

Conversation

@Agbelomo

Copy link
Copy Markdown

Refactor get_full_audit_state single-pass efficiency, decouple telemetry resets, support multi-generation outage history, and enforce prune_history_by_age range validation

Closes #507
Closes #508
Closes #509
Closes #510

Summary

This PR addresses four technical debt items across contract storage access, telemetry counter resets, outage history queries, and history pruning input validation:

  1. get_full_audit_state performs about ten redundant version checks and re-reads the same instance storage per delegated getter #507 - Single-Pass Storage Access for get_full_audit_state: Refactored get_full_audit_state to perform a single check_version call and fetch contract storage keys directly in one pass, eliminating redundant sub-getter delegations and version check overhead.
  2. The telemetry weekly reset wipes fresh violations: calc_stale OR violation_stale resets both lanes, losing a violation recorded a day ago #508 - Decoupled Severity Telemetry Resets: Decoupled calculation and violation staleness reset logic in record_severity_telemetry. Calculation and violation counters are now evaluated and reset independently, preventing stale violation resets from wiping fresh calculation counts (and vice versa).
  3. get_history_by_outage returns entries across config generations with no distinguishing signal: consumers cannot isolate the current decision #509 - Multi-Generation Outage History Context: Documented and verified chronological ordering and config_version_hash generation tracking in get_history_by_outage, allowing backend consumers to distinguish outage recalculations across configuration updates.
  4. prune_history_by_age silently no-ops for min_age_seconds >= now: the cutoff saturates to 0 and no event fires, so callers cannot tell nothing was pruned #510 - Input Validation for prune_history_by_age: Added explicit input validation (min_age_seconds < ledger_timestamp), returning Err(SLAError::InvalidInput) when min_age_seconds >= now to prevent invalid or ambiguous pruning requests.

Key Changes


Verification

All cargo tests and checks pass:

  • cargo check --tests
  • cargo test (including all new regression and range validation unit tests)

@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@Agbelomo Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Agbelomo Agbelomo closed this Aug 28, 2026
@Agbelomo
Agbelomo deleted the Debt/issues branch August 28, 2026 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment