Description
Archival is manual and disconnected from the storage-tier framework. contracts/predictify-hybrid/src/event_archive.rs exposes archive_event and prune_archive (capped by MAX_ARCHIVE_SIZE), but archiving is admin-triggered per market and does not adjust storage TTLs. Meanwhile contracts/predictify-hybrid/src/storage.rs defines per-type TTL tiers (MARKET_TTL_LEDGERS, EVENT_TTL_LEDGERS, ARCHIVE_TTL_LEDGERS, a StorageTtlTier enum) and a CompressedMarket framework. This issue connects archival to the tiered TTL/compression model so resolved markets are demoted to a cheaper tier automatically.
Requirements and context
- Archival API:
EventArchiveManager::archive_event (event_archive.rs:59), prune_archive (event_archive.rs:119), MAX_ARCHIVE_SIZE, and Error::ArchiveFull.
- Storage tiers/compression:
StorageTtlTier and the TTL constants in storage.rs:10-16, plus CompressedMarket/compression config (storage.rs:46+).
- On archival, apply the
ARCHIVE_TTL_LEDGERS tier (extend/bump TTL appropriately) instead of leaving the data on the hot MARKET_TTL_LEDGERS tier; optionally trigger compression for eligible aged markets.
- Add an admin-callable sweep that archives all markets resolved beyond a configurable age, respecting
MAX_ARCHIVE_SIZE and emitting events.
- Non-functional: bound the sweep per call (no unbounded iteration), keep idempotency (re-archiving returns the existing
AlreadyClaimed/already-archived guard), and preserve historical query access.
Acceptance criteria
Suggested execution
1. Fork the repo and create a branch — git checkout -b feature/auto-archival-tiers.
2. Implement changes — contracts/predictify-hybrid/src/event_archive.rs and contracts/predictify-hybrid/src/storage.rs; admin sweep entrypoint in contracts/predictify-hybrid/src/lib.rs.
3. Write/extend tests — extend contracts/predictify-hybrid/src/storage_layout_tests.rs and the archive tests.
4. Test and commit
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test -p predictify-hybrid
stellar contract build --verbose
Example commit message
improvement: auto-archive resolved markets into archive TTL tier
Guidelines
≥90% coverage on tier/sweep paths. Add doc-comments and update docs/contracts/EVENT_ARCHIVE.md, docs/contracts/STORAGE_LAYOUT.md, and ARCHIVE_BOUNDS_IMPLEMENTATION.md. Timeframe: 96 hours.
Description
Archival is manual and disconnected from the storage-tier framework.
contracts/predictify-hybrid/src/event_archive.rsexposesarchive_eventandprune_archive(capped byMAX_ARCHIVE_SIZE), but archiving is admin-triggered per market and does not adjust storage TTLs. Meanwhilecontracts/predictify-hybrid/src/storage.rsdefines per-type TTL tiers (MARKET_TTL_LEDGERS,EVENT_TTL_LEDGERS,ARCHIVE_TTL_LEDGERS, aStorageTtlTierenum) and aCompressedMarketframework. This issue connects archival to the tiered TTL/compression model so resolved markets are demoted to a cheaper tier automatically.Requirements and context
EventArchiveManager::archive_event(event_archive.rs:59),prune_archive(event_archive.rs:119),MAX_ARCHIVE_SIZE, andError::ArchiveFull.StorageTtlTierand the TTL constants instorage.rs:10-16, plusCompressedMarket/compression config (storage.rs:46+).ARCHIVE_TTL_LEDGERStier (extend/bump TTL appropriately) instead of leaving the data on the hotMARKET_TTL_LEDGERStier; optionally trigger compression for eligible aged markets.MAX_ARCHIVE_SIZEand emitting events.AlreadyClaimed/already-archived guard), and preserve historical query access.Acceptance criteria
MAX_ARCHIVE_SIZEwithError::ArchiveFull.cargo fmt,cargo clippy, andcargo testpass.Suggested execution
1. Fork the repo and create a branch —
git checkout -b feature/auto-archival-tiers.2. Implement changes —
contracts/predictify-hybrid/src/event_archive.rsandcontracts/predictify-hybrid/src/storage.rs; admin sweep entrypoint incontracts/predictify-hybrid/src/lib.rs.3. Write/extend tests — extend
contracts/predictify-hybrid/src/storage_layout_tests.rsand the archive tests.4. Test and commit
cargo fmt --all -- --check cargo clippy --all-targets --all-features -- -D warnings cargo test -p predictify-hybrid stellar contract build --verboseExample commit message
Guidelines
≥90% coverage on tier/sweep paths. Add doc-comments and update
docs/contracts/EVENT_ARCHIVE.md,docs/contracts/STORAGE_LAYOUT.md, andARCHIVE_BOUNDS_IMPLEMENTATION.md. Timeframe: 96 hours.