test: expand test coverage for telemetry, multi-generation history. - #534
Open
Agbelomo wants to merge 1 commit into
Open
test: expand test coverage for telemetry, multi-generation history.#534Agbelomo wants to merge 1 commit into
Agbelomo wants to merge 1 commit into
Conversation
…nd history pruning, and remove parity baseline file.
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.
Refactor
get_full_audit_statesingle-pass storage access, decouple telemetry resets, support multi-generation outage history, and validateprune_history_by_ageCloses #507
Closes #508
Closes #509
Closes #510
Summary
This PR addresses four technical debt items in the
apexchainx_calculatorcontract across storage access efficiency, telemetry counter reset logic, outage history query semantics, and age-based retention pruning validation:get_full_audit_state: Refactoredget_full_audit_stateinapexchainx_calculator/src/lib.rsto execute a singlecheck_version(&env)check and read storage keys (ADMIN_KEY,OPERATOR_KEY,PENDING_ADMIN_KEY,PENDING_OP_KEY,PAUSED_KEY,PAUSE_INFO_KEY,STATS_KEY,HISTORY_KEY) directly in one pass. Optimizedget_config_snapshotandbuild_config_snapshotto readCONFIG_KEYonce.calc_staleandviolation_stalecounter reset logic inrecord_severity_telemetry(calculation.rs&lib.rs). Each lane counter is now evaluated and reset independently, ensuring fresh violation data survives stale calculation resets (and vice versa).get_history_by_outageordering (oldest-first, latest decision last). Each entry carries itsconfig_version_hash, enabling consumers to distinguish entries across configuration generations.prune_history_by_ageRange Validation: Added explicit range validation toprune_history_by_ageinhistory.rsandlib.rs. Invocations withmin_age_seconds >= current_ledger_timestampare rejected withErr(SLAError::InvalidInput)to prevent silent no-ops.Changes Made
apexchainx_calculator/src/lib.rs: Single-passget_full_audit_state, optimizedbuild_config_snapshot, decoupled telemetry reset,min_age_secondsvalidation, updated docstrings.apexchainx_calculator/src/calculation.rs: Decoupledcalc_staleandviolation_stalereset logic inrecord_severity_telemetry.apexchainx_calculator/src/history.rs: Addedmin_age_seconds >= nowvalidation returningErr(SLAError::InvalidInput), updatedget_history_by_outagedocstring.apexchainx_calculator/src/tests.rs: Added unit teststest_get_full_audit_state_single_pass_efficiency,test_record_severity_telemetry_decoupled_lane_resets,test_get_history_by_outage_multi_generation_history,test_prune_by_age_rejects_min_age_equal_to_now, andtest_prune_by_age_rejects_min_age_greater_than_now.Verification
cargo check --tests: PASSEDcargo test: PASSED (all 594 test cases passing)