Skip to content

Conversation

vas3a
Copy link
Collaborator

@vas3a vas3a commented Oct 3, 2025

https://topcoder.atlassian.net/browse/PM-1551 - Integrate webhook event processing with tc workflow

-> event from kafka received for scan complete
-> SubmissionScanCompleteOrchestrator catches it and calls the workflowQueueHandler to queue all the necessary ai workflows
-> WorkflowQueueHandler starts a Prisma TX and creates the DB workflowRun entries with a "INIT" status
-> WorkflowQueueHandler calls QueueSchedulerService.queueJob for each workflowRun (DISPATCH_AI_REVIEW_WORKFLOWS and PG_BOSS_DB_URL env vars need to be set for this to happen)
-> QueueSchedulerService registers the queued jobs
-> WorkflowQueueHandler marks the workflowRuns as "QUEUED"
-> QueueSchedulerService starts processing the jobs queue (via pgboss) and takes each job in each queue (each git workflow has it's own queue created based on the aiWorkflow.gitWorkflowId)
-> WorkflowQueueHandler takes care of processing the queue job, and with the help of giteaService it dispatches a git workflow run
-> Webhook service catches the git events and for "workflow_job" it will call WorkflowQueueHandler.handleWorkflowRunEvents.
-> WorkflowQueueHandler handles the webook events, and depending on the event received it will:

  • sync our db with the git workflow run ID
  • fetches the aiWorkflowId and jobsCount from the git workflow logs and stores them in our db for future use
  • moves the aiWorkflowRun in " in progress" and "completed"/"failed"/"cancelled"
  • marks the QueueSchedulerService job as "completed" (otherwise the process will be in progress and next job won't be fetched)

And that's pretty much it.

@vas3a vas3a requested review from jmgasper and kkartunov October 5, 2025 20:19
@vas3a vas3a changed the title [DRAFT] PM-1551 - integrate the AI workflow events PM-1551 - integrate the AI workflow events Oct 5, 2025
);
return;
}
if (!process.env.PGBOSS_DATABASE_URL) {
Copy link

Choose a reason for hiding this comment

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

The environment variable name has been changed from PG_BOSS_DB_URL to PGBOSS_DATABASE_URL. Ensure that this change is reflected in all relevant documentation and deployment configurations to avoid runtime errors.

);
}
this.logger.log('QueueSchedulerService initialized');
this.boss = new PgBoss(process.env.PGBOSS_DATABASE_URL);
Copy link

Choose a reason for hiding this comment

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

The constructor for PgBoss now uses process.env.PGBOSS_DATABASE_URL instead of process.env.PG_BOSS_DB_URL. Verify that this change is consistent across the codebase and that the new environment variable is correctly set in all environments.

Copy link
Contributor

@kkartunov kkartunov left a comment

Choose a reason for hiding this comment

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

Looks good. Merging for testing.

@kkartunov kkartunov merged commit 92c8e83 into develop Oct 6, 2025
1 check passed
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.

2 participants