Skip to content

feat: add pull piece cleanup job for expired pieces#523

Open
silent-cipher wants to merge 5 commits into
feat/pull-flow-testingfrom
feat/pull-piece-cleanup
Open

feat: add pull piece cleanup job for expired pieces#523
silent-cipher wants to merge 5 commits into
feat/pull-flow-testingfrom
feat/pull-piece-cleanup

Conversation

@silent-cipher
Copy link
Copy Markdown
Collaborator

@FilOzzy FilOzzy added this to FOC May 12, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC May 12, 2026
@silent-cipher silent-cipher requested a review from Copilot May 12, 2026 06:54
@silent-cipher silent-cipher self-assigned this May 12, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_cleanup as 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.

Comment thread apps/backend/src/config/app.config.ts
Comment thread apps/backend/src/pull-check/pull-piece.repository.ts Outdated
Comment thread apps/backend/src/pull-check/pull-check.service.ts
Copy link
Copy Markdown
Collaborator

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread apps/backend/src/pull-check/pull-piece.repository.ts
@github-project-automation github-project-automation Bot moved this from 📌 Triage to ✔️ Approved by reviewer in FOC May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✔️ Approved by reviewer

Development

Successfully merging this pull request may close these issues.

4 participants