feat: add pull piece cleanup job for expired pieces#523
Open
silent-cipher wants to merge 5 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a global pg-boss scheduled job to periodically delete expired pull_pieces registrations created by pull checks, and exposes configuration/docs for controlling its cadence.
Changes:
- Introduces
pull_piece_cleanupas a new global scheduled job/queue and wires it into pg-boss scheduling, workers, and metrics. - Adds
PULL_PIECE_CLEANUP_INTERVAL_SECONDS(validated via Joi) and threads it through backend config and scheduling. - Adds repository/service support for deleting expired
pull_pieces, plus documentation updates.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/environment-variables.md | Documents new PULL_PIECE_CLEANUP_INTERVAL_SECONDS env var and adds it to the quick reference table. |
| docs/checks/pull-check.md | Adds the new cleanup interval env var to pull-check docs. |
| apps/backend/src/pull-check/pull-piece.repository.ts | Adds deleteExpired() DB deletion helper for expired registrations. |
| apps/backend/src/pull-check/pull-check.service.ts | Adds deleteExpiredPullPieces() entry point for the scheduled cleanup job. |
| apps/backend/src/pull-check/pull-check.service.spec.ts | Updates pull-piece config fixture to include the new interval setting. |
| apps/backend/src/jobs/repositories/job-schedule.repository.ts | Updates pg-boss job-state mapping to include the new cleanup queue/type. |
| apps/backend/src/jobs/jobs.service.ts | Creates queue/worker, schedules pull_piece_cleanup, enqueues it, and updates metrics handling. |
| apps/backend/src/jobs/jobs.service.spec.ts | Updates config fixture and asserts the new worker queue is registered/created. |
| apps/backend/src/jobs/job-queues.ts | Defines PULL_PIECE_CLEANUP_QUEUE constant. |
| apps/backend/src/database/entities/job-schedule-state.entity.ts | Extends JobType union with pull_piece_cleanup. |
| apps/backend/src/config/app.config.ts | Adds env var validation and config plumbing for pullPieceCleanupIntervalSeconds. |
SgtPooki
approved these changes
May 12, 2026
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.
#504 (comment)