Skip to content

feat(keeper): implement database migration and archival strategy (#438)#499

Merged
ayomideadeniran merged 1 commit into
SoroLabs:mainfrom
Danielodingz:feat/438-database-migration-archival-strategy
May 31, 2026
Merged

feat(keeper): implement database migration and archival strategy (#438)#499
ayomideadeniran merged 1 commit into
SoroLabs:mainfrom
Danielodingz:feat/438-database-migration-archival-strategy

Conversation

@Danielodingz
Copy link
Copy Markdown
Contributor

Closes #438

feat(keeper): Database Migration and Archival Strategy (#438)

Summary

Implements the core architecture for issue #438 — a robust system for managing massive execution logs, with automated archiving to cold storage and seamless queryability across both hot and cold storage layers.

As agreed with the maintainer, the implementation is delivered as a self-contained module (keeper/src/archival-strategy/) ready to be wired into the existing infrastructure.


Changes

New module: keeper/src/archival-strategy/

File Description
errorTracker.js Circuit breaker + error aggregation. Trips after 5 consecutive failures, halting all downstream operations to prevent cascading failures.
migrator.js Fault-tolerant schema migrations using BEGIN TRANSACTION / COMMIT / ROLLBACK. Safe to run with zero downtime.
archiver.js Batched archival pipeline — fetches old logs from the hot DB, writes to cold storage, then deletes from hot DB. Configurable batchSize and daysOld.
queryEngine.js Unified query interface that transparently routes requests to hot DB, cold storage, or both depending on the requested time window.
index.js Barrel export for clean integration.

New tests: keeper/__tests__/archival-strategy/

  • errorTracker.test.js
  • migrator.test.js
  • archiver.test.js
  • queryEngine.test.js
  • index.test.js

New documentation: keeper/ARCHIVAL_STRATEGY_DOCS.md


Test Coverage

Test Suites: 5 passed, 5 total
Tests:       23 passed, 23 total

File             | % Stmts | % Branch | % Funcs | % Lines
-----------------|---------|----------|---------|--------
All files        |     100 |      100 |     100 |     100

Exceeds the >90% coverage requirement across all metrics.


Acceptance Criteria

  • Feature implemented according to requirements
  • Unit and integration tests passing (23/23)
  • Security review completed (documented in ARCHIVAL_STRATEGY_DOCS.md)
  • Comprehensive documentation written

Integration Notes for Maintainer

To wire this into the live system:

  1. Replace the cold storage mock in archiver.js with the actual cloud storage client (e.g. AWS S3, GCS).
  2. Schedule archiver.archiveOldLogs() via the existing cron/background worker.
  3. Route existing log query endpoints through queryEngine.fetchLogs().

…oLabs#438)

- Add ErrorTracker with circuit breaker pattern for fallback resilience
- Add Migrator with transactional schema migrations and rollback support
- Add Archiver with batched hot-to-cold log archival pipeline
- Add QueryEngine for unified hot/cold storage querying by time window
- Add barrel index export for clean integration
- Add 23 unit/integration tests with 100% coverage (statements, branches, functions, lines)
- Add ARCHIVAL_STRATEGY_DOCS.md with architecture, security review, and integration guide
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 30, 2026

@Danielodingz 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

@Danielodingz
Copy link
Copy Markdown
Contributor Author

Hello @ayomideadeniran please review and merge. Thank you

@ACodehunter
Copy link
Copy Markdown

Pr under review

@ayomideadeniran ayomideadeniran merged commit 3a00675 into SoroLabs:main May 31, 2026
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.

[Backend] Create Robust Database Migration and Archival Strategy

3 participants