Skip to content

[437] [High] Replace Polling Sweeper with a Deadline-Scheduled Job Queue - #550

Merged
james2177 merged 2 commits into
stellar-vortex-protocol:mainfrom
Goodnessukaigwe:fix/437-high-replace-polling-sweeper-with-a-deadline-scheduled-job-queue
Sep 30, 2026
Merged

james2177 merged 2 commits into
stellar-vortex-protocol:mainfrom
Goodnessukaigwe:fix/437-high-replace-polling-sweeper-with-a-deadline-scheduled-job-queue

Conversation

@Goodnessukaigwe

Copy link
Copy Markdown

Summary

  • Arms expire-intent when an intent is created and fill-window-expired when it is accepted or its fill deadline is extended, using the existing job queue (delayMs plus an idempotency key of job:intentId:deadline).
  • Handlers re-check state and the stored deadline, so a stale job from a moved deadline, a cancel, or a fill is a no-op. There is no queue cancel API.
  • The leader-elected sweep remains as a safety net at SAFETY_SWEEP_INTERVAL_MS (default 5 minutes). Intents it still has to expire or slash increment vortex_sweeper_safety_caught_total (steady state ~0). triggerManualSweep is unchanged.

Closes #437

Problem

IntentsSweeperService.sweep scanned every open and accepted intent every 30 seconds. Expiry waited up to that interval, and the scan grew with intent volume.

Solution

Deadline jobs are the primary path and fire at the deadline (p99 under 2s in the timer test). The safety sweep only catches jobs the queue did not run. Queue technology is unchanged: JOBS_DRIVER is still memory or bullmq (ADR 0002). ADR 0005 records the choice.

Test plan

  • Create an intent whose deadline is about a second out and confirm it expires without waiting for the safety sweep
  • Accept an intent, let the fill window pass, and confirm the solver is slashed by fill-window-expired
  • Move a deadline and confirm the old job does not expire or slash the intent
  • SIGUSR2 / triggerManualSweep still runs one sweep
  • vortex_sweeper_safety_caught_total stays at 0 when deadline jobs are running

Made with Cursor

Arm expire-intent and fill-window-expired at create, accept, and deadline extension, and keep a slower safety sweep for jobs the queue misses.

Co-authored-by: Cursor <cursoragent@cursor.com>
@drips-wave

drips-wave Bot commented Sep 29, 2026

Copy link
Copy Markdown

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

…e-polling-sweeper-with-a-deadline-scheduled-job-queue

# Conflicts:
#	.env.example
#	CHANGELOG.md
#	docs/runbooks/on-call.md
#	jest.config.js
#	package-lock.json
#	package.json
#	src/app.module.ts
#	src/common/stellar-signature.ts
#	src/config/configuration.ts
#	src/config/env.validation.ts
#	src/governance/governance.module.ts
#	src/intents/intents-sweeper.service.ts
#	src/intents/intents.gateway.spec.ts
#	src/intents/intents.gateway.ts
#	src/intents/intents.module.ts
#	src/intents/intents.service.shadow.spec.ts
#	src/intents/intents.service.spec.ts
#	src/intents/solver-intent-matcher.ts
#	src/intents/ws/connection-state.ts
#	src/metrics/metrics.service.ts
#	src/solvers/solvers.controller.ts
#	src/soroban/event-ingestion.service.ts
#	src/soroban/signer.service.spec.ts
#	src/soroban/solver-registry.service.spec.ts
#	src/soroban/soroban.controller.spec.ts
#	src/soroban/soroban.module.ts
#	src/soroban/soroban.service.ts
#	src/soroban/stellar-tx.service.spec.ts
#	src/soroban/stellar-tx.service.ts
#	src/soroban/tx-confirmation.service.ts
#	src/tokens/in-memory-tokens.repository.ts
#	src/tokens/tokens.service.ts
#	src/treasury/treasury.service.spec.ts
#	src/treasury/treasury.service.ts
#	test/jest-e2e.json
@james2177
james2177 merged commit ad79f20 into stellar-vortex-protocol:main Sep 30, 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.

[High] Replace Polling Sweeper with a Deadline-Scheduled Job Queue

2 participants