Skip to content

est(reporting): add idempotency coverage for archive cleanup and document safety guarantees#407

Open
IbrahimIjai wants to merge 6 commits intoRemitwise-Org:mainfrom
IbrahimIjai:test/reporting-cleanup-idempotency
Open

est(reporting): add idempotency coverage for archive cleanup and document safety guarantees#407
IbrahimIjai wants to merge 6 commits intoRemitwise-Org:mainfrom
IbrahimIjai:test/reporting-cleanup-idempotency

Conversation

@IbrahimIjai
Copy link
Copy Markdown

@IbrahimIjai IbrahimIjai commented Mar 26, 2026

closes: #314

test(reporting): add idempotency coverage for archive cleanup and document safety guarantees

PR Description

Summary
This PR adds explicit idempotency coverage for reporting archive cleanup to ensure repeated cleanup calls are safe, non-duplicative, and do not corrupt storage counters.

What Changed
Added NatSpec-style docs to cleanup_old_reports in reporting/src/lib.rs:
Admin-only behavior
Idempotency guarantee for repeated calls with the same cutoff
Added comprehensive idempotency tests in reporting/src/tests.rs:
Repeated cleanup with same cutoff returns 0 after first deletion
No duplicate deletions across staggered cutoffs
Storage stats remain consistent across cleanup retries
Updated documentation:
reporting/README.md with archive cleanup idempotency and security notes
Root README.md with reporting cleanup safety guarantees
Security Notes
Cleanup and archiving remain admin-gated.
Unauthorized calls fail before mutation.
Deletions are map-key based, preventing double-deletion accounting.
Cleanup scope is limited to archived records older than the supplied cutoff.
Test Status
Attempted:

cargo test -p reporting
Blocked by pre-existing workspace compile errors in remitwise-common (duplicate constants):

INSTANCE_BUMP_AMOUNT defined twice
INSTANCE_LIFETIME_THRESHOLD defined twice
This blocker is outside the files changed in this PR.

Codex added 5 commits March 26, 2026 02:17
…modules, alongside extensive new tests and examples for various contracts.
… a common utility library, comprehensive tests, and updated gas benchmarks.
Add a new test `test_cleanup_old_reports_repeated_partial_cleanup_preserves_remaining_archives_and_counters` to verify that calling `cleanup_old_reports` multiple times with the same cutoff correctly preserves remaining active and archived reports without duplicate deletions. This ensures the cleanup logic is idempotent and maintains accurate storage statistics across sequential operations.
@IbrahimIjai
Copy link
Copy Markdown
Author

@Hahfyeex @johnsmccain kindly check my pr.

@Baskarayelu
Copy link
Copy Markdown
Contributor

@IbrahimIjai Please resolve the conflicts

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.

Add cleanup idempotency tests for reporting archives

2 participants