11# PyTorch Bot Architecture Analysis
22
3+ - [ PyTorch Bot Architecture Analysis] ( #pytorch-bot-architecture-analysis )
4+ - [ Overview] ( #overview )
5+ - [ Core Architecture] ( #core-architecture )
6+ - [ Entry Points] ( #entry-points )
7+ - [ Command System] ( #command-system )
8+ - [ Permission System (` lib/bot/utils.ts:248 ` )] ( #permission-system-libbotutilsts248 )
9+ - [ Bot Modules] ( #bot-modules )
10+ - [ Core Command Bots] ( #core-command-bots )
11+ - [ Automation Bots] ( #automation-bots )
12+ - [ CI Integration Bots] ( #ci-integration-bots )
13+ - [ Security \& Review Bots] ( #security--review-bots )
14+ - [ Infrastructure Bots] ( #infrastructure-bots )
15+ - [ Detailed Bot Analysis] ( #detailed-bot-analysis )
16+ - [ 1. autoLabelBot.ts] ( #1-autolabelbotts )
17+ - [ 2. autoCcBot.ts] ( #2-autoccbotts )
18+ - [ 3. retryBot.ts] ( #3-retrybotts )
19+ - [ 4. ciflowPushTrigger.ts] ( #4-ciflowpushtriggerts )
20+ - [ Configuration (ciflow_push_tags)] ( #configuration-ciflow_push_tags )
21+ - [ 5. cancelWorkflowsOnCloseBot.ts] ( #5-cancelworkflowsonclosebotts )
22+ - [ 6. verifyDisableTestIssueBot.ts] ( #6-verifydisabletestissuebotts )
23+ - [ 7. stripApprovalBot.ts] ( #7-stripapprovalbotts )
24+ - [ 8. codevNoWritePermBot.ts] ( #8-codevnowritepermbotts )
25+ - [ 9. drciBot.ts] ( #9-drcibotts )
26+ - [ 10. webhookToDynamo.ts] ( #10-webhooktodynamots )
27+ - [ External Integrations] ( #external-integrations )
28+ - [ Data Storage] ( #data-storage )
29+ - [ CI Systems] ( #ci-systems )
30+ - [ Configuration Management] ( #configuration-management )
31+ - [ Key Features] ( #key-features )
32+ - [ Intelligent Merge System] ( #intelligent-merge-system )
33+ - [ Smart Retry Logic (` retryBot.ts ` )] ( #smart-retry-logic-retrybotts )
34+ - [ Permission-based Security] ( #permission-based-security )
35+ - [ Auto-labeling Intelligence] ( #auto-labeling-intelligence )
36+ - [ Data Flow] ( #data-flow )
37+ - [ Integration Architecture] ( #integration-architecture )
38+ - [ Deployment Context] ( #deployment-context )
39+ - [ Configuration Files] ( #configuration-files )
40+
341## Overview
442
543The PyTorch bot is a GitHub webhook automation system built with ** Probot** that manages CI/CD workflows, code reviews, and development operations for the PyTorch ecosystem. It's deployed as a Next.js application on Vercel and integrates with multiple external services.
@@ -47,20 +85,18 @@ The bot supports these primary commands:
4785
4886### CI Integration Bots
4987
50- 8 . ** triggerCircleCIWorkflows** - CircleCI pipeline integration
51- 9 . ** triggerInductorTestsBot** - PyTorch Inductor test triggering
52- 10 . ** verifyDisableTestIssueBot** - Test disabling authorization
88+ 8 . ** verifyDisableTestIssueBot** - Test disabling authorization
5389
5490### Security & Review Bots
5591
56- 11 . ** stripApprovalBot** - Removes approvals on PR reopen
57- 12 . ** codevNoWritePermBot** - Notifies about permission requirements
58- 13 . ** drciBot** - Dr. CI dashboard integration
92+ 9 . ** stripApprovalBot** - Removes approvals on PR reopen
93+ 10 . ** codevNoWritePermBot** - Notifies about permission requirements
94+ 11 . ** drciBot** - Dr. CI dashboard integration
5995
6096### Infrastructure Bots
6197
62- 14 . ** webhookToDynamo** - Event logging to DynamoDB
63- 15 . ** pytorchbotLogger** - Bot action logging
98+ 12 . ** webhookToDynamo** - Event logging to DynamoDB
99+ 13 . ** pytorchbotLogger** - Bot action logging
64100
65101## Detailed Bot Analysis
66102
@@ -154,44 +190,7 @@ ciflow_push_tags:
154190 - ciflow/foo
155191` ` `
156192
157- ### 5. triggerCircleCIWorkflows.ts
158-
159- **Primary Purpose:** Integrates with CircleCI by triggering workflows based on GitHub events and labels.
160-
161- **Key Features:**
162-
163- - **Label-to-parameter mapping**: Converts GitHub labels to CircleCI pipeline parameters
164- - **Branch/tag filtering**: Different behavior for push events vs. pull requests
165- - **Configuration-driven**: Uses YAML config to define label-to-parameter mappings
166- - **Fork handling**: Special handling for PRs from forked repositories
167- - **Default parameters**: Supports default parameter values for workflows
168-
169- **GitHub Webhooks:**
170-
171- - ` pull_request.labeled`, `pull_request.synchronize`
172- - ` push`
173-
174- **Special Logic:** Translates GitHub repository state into CircleCI pipeline parameters using configurable mappings
175-
176- # ## 6. triggerInductorTestsBot.ts
177-
178- **Primary Purpose:** Allows authorized users to trigger PyTorch Inductor tests via comment commands.
179-
180- **Key Features:**
181-
182- - **Comment-based triggering**: Responds to `@pytorch run pytorch tests` comments
183- - **User authorization**: Restricts access to pre-approved users and repositories
184- - **Cross-repository workflow**: Triggers workflows in pytorch/pytorch-integration-testing
185- - **Commit handling**: Uses appropriate commit SHAs for different repositories
186- - **Error handling**: Provides feedback on success/failure of test triggering
187-
188- **GitHub Webhooks:**
189-
190- - ` issue_comment.created`
191-
192- **Special Logic:** Security-focused with explicit allowlists for users and repositories
193-
194- # ## 7. cancelWorkflowsOnCloseBot.ts
193+ ### 5. cancelWorkflowsOnCloseBot.ts
195194
196195**Primary Purpose:** Cancels running GitHub Actions workflows when PRs are closed to save compute resources.
197196
@@ -209,7 +208,7 @@ ciflow_push_tags:
209208
210209**Special Logic:** Prevents unnecessary resource usage by canceling workflows for closed/abandoned PRs
211210
212- # ## 8 . verifyDisableTestIssueBot.ts
211+ # ## 6 . verifyDisableTestIssueBot.ts
213212
214213**Primary Purpose:** Validates and processes issues that request disabling or marking tests as unstable.
215214
@@ -227,7 +226,7 @@ ciflow_push_tags:
227226
228227**Special Logic:** Critical security component that ensures only authorized users can disable CI tests
229228
230- # ## 9 . stripApprovalBot.ts
229+ # ## 7 . stripApprovalBot.ts
231230
232231**Primary Purpose:** Removes PR approvals when PRs are reopened to ensure fresh review.
233232
@@ -244,7 +243,7 @@ ciflow_push_tags:
244243
245244**Special Logic:** Maintains code review integrity by requiring fresh approvals after PR reopening
246245
247- # ## 10 . codevNoWritePermBot.ts
246+ # ## 8 . codevNoWritePermBot.ts
248247
249248**Primary Purpose:** Notifies Phabricator/Codev users when they need GitHub write permissions for CI.
250249
@@ -261,7 +260,7 @@ ciflow_push_tags:
261260
262261**Special Logic:** Bridges the gap between internal Facebook/Meta development workflow and external GitHub CI requirements
263262
264- # ## 11 . drciBot.ts
263+ # ## 9 . drciBot.ts
265264
266265**Primary Purpose:** Manages Dr. CI (Diagnostic CI) comments that provide comprehensive PR status information.
267266
@@ -278,7 +277,7 @@ ciflow_push_tags:
278277
279278**Special Logic:** Serves as the interface between GitHub PRs and the comprehensive Dr. CI dashboard system
280279
281- # ## 12 . webhookToDynamo.ts
280+ # ## 10 . webhookToDynamo.ts
282281
283282**Primary Purpose:** Logs GitHub webhook events to DynamoDB tables for analytics and auditing.
284283
0 commit comments