jleechanorg-pr-automation 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of jleechanorg-pr-automation might be problematic. Click here for more details.

Files changed (28) hide show
  1. jleechanorg_pr_automation-0.1.1/PKG-INFO +222 -0
  2. jleechanorg_pr_automation-0.1.1/README.md +192 -0
  3. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation/__init__.py +32 -0
  4. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation/automation_safety_manager.py +830 -0
  5. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation/automation_safety_wrapper.py +116 -0
  6. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation/automation_utils.py +314 -0
  7. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation/check_codex_comment.py +76 -0
  8. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation/codex_branch_updater.py +272 -0
  9. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation/codex_config.py +123 -0
  10. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation/jleechanorg_pr_monitor.py +1206 -0
  11. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation/tests/conftest.py +12 -0
  12. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation/tests/test_actionable_counting_matrix.py +221 -0
  13. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation/tests/test_automation_over_running_reproduction.py +157 -0
  14. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation/tests/test_automation_safety_limits.py +462 -0
  15. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation/tests/test_automation_safety_manager_comprehensive.py +659 -0
  16. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation/tests/test_codex_actor_matching.py +137 -0
  17. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation/tests/test_graphql_error_handling.py +155 -0
  18. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation/tests/test_pr_filtering_matrix.py +473 -0
  19. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation/tests/test_pr_targeting.py +118 -0
  20. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation/utils.py +232 -0
  21. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation.egg-info/PKG-INFO +222 -0
  22. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation.egg-info/SOURCES.txt +26 -0
  23. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation.egg-info/dependency_links.txt +1 -0
  24. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation.egg-info/entry_points.txt +3 -0
  25. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation.egg-info/requires.txt +10 -0
  26. jleechanorg_pr_automation-0.1.1/jleechanorg_pr_automation.egg-info/top_level.txt +1 -0
  27. jleechanorg_pr_automation-0.1.1/pyproject.toml +82 -0
  28. jleechanorg_pr_automation-0.1.1/setup.cfg +4 -0
@@ -0,0 +1,222 @@
1
+ Metadata-Version: 2.4
2
+ Name: jleechanorg-pr-automation
3
+ Version: 0.1.1
4
+ Summary: GitHub PR automation system with safety limits and actionable counting
5
+ Author-email: jleechan <jlee@jleechan.org>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/jleechanorg/worldarchitect.ai
8
+ Project-URL: Repository, https://github.com/jleechanorg/worldarchitect.ai
9
+ Project-URL: Issues, https://github.com/jleechanorg/worldarchitect.ai/issues
10
+ Keywords: github,automation,pr,pull-request,monitoring
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Classifier: Topic :: Software Development :: Version Control :: Git
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ Requires-Dist: requests>=2.25.0
23
+ Provides-Extra: email
24
+ Requires-Dist: keyring>=23.0.0; extra == "email"
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
27
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
28
+ Requires-Dist: black>=22.0.0; extra == "dev"
29
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
30
+
31
+ # jleechanorg-pr-automation
32
+
33
+ A comprehensive GitHub PR automation system with safety limits, actionable counting, and intelligent filtering.
34
+
35
+ ## Features
36
+
37
+ - **Actionable PR Counting**: Only processes PRs that need attention, excluding already-processed ones
38
+ - **Safety Limits**: Built-in rate limiting and attempt tracking to prevent automation abuse
39
+ - **Cross-Process Safety**: Thread-safe operations with file-based persistence
40
+ - **Email Notifications**: Optional SMTP integration for automation alerts
41
+ - **Commit-Based Tracking**: Avoids duplicate processing using commit SHAs
42
+ - **Comprehensive Testing**: 200+ test cases with matrix-driven coverage
43
+
44
+ ## Installation
45
+
46
+ ```bash
47
+ pip install jleechanorg-pr-automation
48
+ ```
49
+
50
+ ### Optional Dependencies
51
+
52
+ For email notifications:
53
+ ```bash
54
+ pip install jleechanorg-pr-automation[email]
55
+ ```
56
+
57
+ For development:
58
+ ```bash
59
+ pip install jleechanorg-pr-automation[dev]
60
+ ```
61
+
62
+ ## Quick Start
63
+
64
+ ### Basic PR Monitoring
65
+
66
+ ```python
67
+ from jleechanorg_pr_automation import JleechanorgPRMonitor
68
+
69
+ # Initialize monitor
70
+ monitor = JleechanorgPRMonitor()
71
+
72
+ # Process up to 20 actionable PRs
73
+ result = monitor.run_monitoring_cycle_with_actionable_count(target_actionable_count=20)
74
+
75
+ print(f"Processed {result['actionable_processed']} actionable PRs")
76
+ print(f"Skipped {result['skipped_count']} non-actionable PRs")
77
+ ```
78
+
79
+ ### Safety Management
80
+
81
+ ```python
82
+ from jleechanorg_pr_automation import AutomationSafetyManager
83
+
84
+ # Initialize safety manager with data directory
85
+ safety = AutomationSafetyManager(data_dir="/tmp/automation_safety")
86
+
87
+ # Limits are configured via automation_safety_config.json inside the data directory
88
+ # or the AUTOMATION_PR_LIMIT / AUTOMATION_GLOBAL_LIMIT environment variables.
89
+
90
+ # Check if PR can be processed
91
+ if safety.can_process_pr(pr_number=123, repo="my-repo"):
92
+ # Process PR...
93
+ safety.record_pr_attempt(pr_number=123, result="success", repo="my-repo")
94
+ ```
95
+
96
+ ## Configuration
97
+
98
+ ### Environment Variables
99
+
100
+ - `GITHUB_TOKEN`: GitHub personal access token (required)
101
+ - `PR_AUTOMATION_WORKSPACE`: Custom workspace directory (optional)
102
+ - `AUTOMATION_PR_LIMIT`: Maximum attempts per PR (default: 5)
103
+ - `AUTOMATION_GLOBAL_LIMIT`: Maximum global automation runs (default: 50)
104
+ - `AUTOMATION_APPROVAL_HOURS`: Hours before approval expires (default: 24)
105
+
106
+ ### Email Configuration (Optional)
107
+
108
+ - `SMTP_SERVER`: SMTP server hostname
109
+ - `SMTP_PORT`: SMTP server port (default: 587)
110
+ - `EMAIL_USER`: SMTP username
111
+ - `EMAIL_PASS`: SMTP password
112
+ - `EMAIL_TO`: Notification recipient
113
+ - `EMAIL_FROM`: Sender address (defaults to EMAIL_USER)
114
+
115
+ ## Command Line Interface
116
+
117
+ ### PR Monitor
118
+
119
+ ```bash
120
+ # Monitor all repositories
121
+ jleechanorg-pr-monitor
122
+
123
+ # Process specific repository
124
+ jleechanorg-pr-monitor --single-repo worldarchitect.ai
125
+
126
+ # Process specific PR
127
+ jleechanorg-pr-monitor --target-pr 123 --target-repo jleechanorg/worldarchitect.ai
128
+
129
+ # Dry run (discovery only)
130
+ jleechanorg-pr-monitor --dry-run
131
+ ```
132
+
133
+ ### Safety Manager CLI
134
+
135
+ ```bash
136
+ # Check current status
137
+ automation-safety-cli status
138
+
139
+ # Clear all safety data
140
+ automation-safety-cli clear
141
+
142
+ # Check specific PR
143
+ automation-safety-cli check-pr 123 --repo my-repo
144
+ ```
145
+
146
+ ## Architecture
147
+
148
+ ### Actionable PR Logic
149
+
150
+ The system implements intelligent PR filtering:
151
+
152
+ 1. **State Check**: Only processes open PRs
153
+ 2. **Commit Tracking**: Skips PRs already processed with current commit SHA
154
+ 3. **Safety Limits**: Respects per-PR and global automation limits
155
+ 4. **Ordering**: Processes most recently updated PRs first
156
+
157
+ ### Safety Features
158
+
159
+ - **Dual Limiting**: Per-PR consecutive failure limits + global run limits
160
+ - **Cross-Process Safety**: File-based locking for concurrent automation instances
161
+ - **Attempt Tracking**: Full history of success/failure with timestamps
162
+ - **Graceful Degradation**: Continues processing other PRs if one fails
163
+
164
+ ### Testing
165
+
166
+ The library includes comprehensive test coverage:
167
+
168
+ - **Matrix Testing**: All PR state combinations (Open/Closed × New/Old Commits × Processed/Fresh)
169
+ - **Actionable Counting**: Batch processing with skip exclusion
170
+ - **Safety Limits**: Concurrent access and edge cases
171
+ - **Integration Tests**: Real GitHub API interactions (optional)
172
+
173
+ ## Development
174
+
175
+ ```bash
176
+ # Clone repository
177
+ git clone https://github.com/jleechanorg/worldarchitect.ai.git
178
+ cd worldarchitect.ai/automation
179
+
180
+ # Install in development mode
181
+ pip install -e .[dev]
182
+
183
+ # Run tests
184
+ pytest
185
+
186
+ # Run tests with coverage
187
+ pytest --cov=jleechanorg_pr_automation
188
+
189
+ # Format code
190
+ black .
191
+ ruff check .
192
+ ```
193
+
194
+ ## Contributing
195
+
196
+ 1. Fork the repository
197
+ 2. Create a feature branch
198
+ 3. Add tests for new functionality
199
+ 4. Ensure all tests pass
200
+ 5. Submit a pull request
201
+
202
+ ## License
203
+
204
+ MIT License - see LICENSE file for details.
205
+
206
+ ## Changelog
207
+
208
+ ### 0.1.1 (2025-10-06)
209
+
210
+ - Fix daily reset of global automation limit so automation never stalls overnight
211
+ - Track latest reset timestamp in safety data for observability
212
+ - Expand safety manager tests to cover daily rollover behaviour
213
+
214
+ ### 0.1.0 (2025-09-28)
215
+
216
+ - Initial release
217
+ - Actionable PR counting system
218
+ - Safety management with dual limits
219
+ - Cross-process file-based persistence
220
+ - Email notification support
221
+ - Comprehensive test suite (200+ tests)
222
+ - CLI interfaces for monitoring and safety management
@@ -0,0 +1,192 @@
1
+ # jleechanorg-pr-automation
2
+
3
+ A comprehensive GitHub PR automation system with safety limits, actionable counting, and intelligent filtering.
4
+
5
+ ## Features
6
+
7
+ - **Actionable PR Counting**: Only processes PRs that need attention, excluding already-processed ones
8
+ - **Safety Limits**: Built-in rate limiting and attempt tracking to prevent automation abuse
9
+ - **Cross-Process Safety**: Thread-safe operations with file-based persistence
10
+ - **Email Notifications**: Optional SMTP integration for automation alerts
11
+ - **Commit-Based Tracking**: Avoids duplicate processing using commit SHAs
12
+ - **Comprehensive Testing**: 200+ test cases with matrix-driven coverage
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pip install jleechanorg-pr-automation
18
+ ```
19
+
20
+ ### Optional Dependencies
21
+
22
+ For email notifications:
23
+ ```bash
24
+ pip install jleechanorg-pr-automation[email]
25
+ ```
26
+
27
+ For development:
28
+ ```bash
29
+ pip install jleechanorg-pr-automation[dev]
30
+ ```
31
+
32
+ ## Quick Start
33
+
34
+ ### Basic PR Monitoring
35
+
36
+ ```python
37
+ from jleechanorg_pr_automation import JleechanorgPRMonitor
38
+
39
+ # Initialize monitor
40
+ monitor = JleechanorgPRMonitor()
41
+
42
+ # Process up to 20 actionable PRs
43
+ result = monitor.run_monitoring_cycle_with_actionable_count(target_actionable_count=20)
44
+
45
+ print(f"Processed {result['actionable_processed']} actionable PRs")
46
+ print(f"Skipped {result['skipped_count']} non-actionable PRs")
47
+ ```
48
+
49
+ ### Safety Management
50
+
51
+ ```python
52
+ from jleechanorg_pr_automation import AutomationSafetyManager
53
+
54
+ # Initialize safety manager with data directory
55
+ safety = AutomationSafetyManager(data_dir="/tmp/automation_safety")
56
+
57
+ # Limits are configured via automation_safety_config.json inside the data directory
58
+ # or the AUTOMATION_PR_LIMIT / AUTOMATION_GLOBAL_LIMIT environment variables.
59
+
60
+ # Check if PR can be processed
61
+ if safety.can_process_pr(pr_number=123, repo="my-repo"):
62
+ # Process PR...
63
+ safety.record_pr_attempt(pr_number=123, result="success", repo="my-repo")
64
+ ```
65
+
66
+ ## Configuration
67
+
68
+ ### Environment Variables
69
+
70
+ - `GITHUB_TOKEN`: GitHub personal access token (required)
71
+ - `PR_AUTOMATION_WORKSPACE`: Custom workspace directory (optional)
72
+ - `AUTOMATION_PR_LIMIT`: Maximum attempts per PR (default: 5)
73
+ - `AUTOMATION_GLOBAL_LIMIT`: Maximum global automation runs (default: 50)
74
+ - `AUTOMATION_APPROVAL_HOURS`: Hours before approval expires (default: 24)
75
+
76
+ ### Email Configuration (Optional)
77
+
78
+ - `SMTP_SERVER`: SMTP server hostname
79
+ - `SMTP_PORT`: SMTP server port (default: 587)
80
+ - `EMAIL_USER`: SMTP username
81
+ - `EMAIL_PASS`: SMTP password
82
+ - `EMAIL_TO`: Notification recipient
83
+ - `EMAIL_FROM`: Sender address (defaults to EMAIL_USER)
84
+
85
+ ## Command Line Interface
86
+
87
+ ### PR Monitor
88
+
89
+ ```bash
90
+ # Monitor all repositories
91
+ jleechanorg-pr-monitor
92
+
93
+ # Process specific repository
94
+ jleechanorg-pr-monitor --single-repo worldarchitect.ai
95
+
96
+ # Process specific PR
97
+ jleechanorg-pr-monitor --target-pr 123 --target-repo jleechanorg/worldarchitect.ai
98
+
99
+ # Dry run (discovery only)
100
+ jleechanorg-pr-monitor --dry-run
101
+ ```
102
+
103
+ ### Safety Manager CLI
104
+
105
+ ```bash
106
+ # Check current status
107
+ automation-safety-cli status
108
+
109
+ # Clear all safety data
110
+ automation-safety-cli clear
111
+
112
+ # Check specific PR
113
+ automation-safety-cli check-pr 123 --repo my-repo
114
+ ```
115
+
116
+ ## Architecture
117
+
118
+ ### Actionable PR Logic
119
+
120
+ The system implements intelligent PR filtering:
121
+
122
+ 1. **State Check**: Only processes open PRs
123
+ 2. **Commit Tracking**: Skips PRs already processed with current commit SHA
124
+ 3. **Safety Limits**: Respects per-PR and global automation limits
125
+ 4. **Ordering**: Processes most recently updated PRs first
126
+
127
+ ### Safety Features
128
+
129
+ - **Dual Limiting**: Per-PR consecutive failure limits + global run limits
130
+ - **Cross-Process Safety**: File-based locking for concurrent automation instances
131
+ - **Attempt Tracking**: Full history of success/failure with timestamps
132
+ - **Graceful Degradation**: Continues processing other PRs if one fails
133
+
134
+ ### Testing
135
+
136
+ The library includes comprehensive test coverage:
137
+
138
+ - **Matrix Testing**: All PR state combinations (Open/Closed × New/Old Commits × Processed/Fresh)
139
+ - **Actionable Counting**: Batch processing with skip exclusion
140
+ - **Safety Limits**: Concurrent access and edge cases
141
+ - **Integration Tests**: Real GitHub API interactions (optional)
142
+
143
+ ## Development
144
+
145
+ ```bash
146
+ # Clone repository
147
+ git clone https://github.com/jleechanorg/worldarchitect.ai.git
148
+ cd worldarchitect.ai/automation
149
+
150
+ # Install in development mode
151
+ pip install -e .[dev]
152
+
153
+ # Run tests
154
+ pytest
155
+
156
+ # Run tests with coverage
157
+ pytest --cov=jleechanorg_pr_automation
158
+
159
+ # Format code
160
+ black .
161
+ ruff check .
162
+ ```
163
+
164
+ ## Contributing
165
+
166
+ 1. Fork the repository
167
+ 2. Create a feature branch
168
+ 3. Add tests for new functionality
169
+ 4. Ensure all tests pass
170
+ 5. Submit a pull request
171
+
172
+ ## License
173
+
174
+ MIT License - see LICENSE file for details.
175
+
176
+ ## Changelog
177
+
178
+ ### 0.1.1 (2025-10-06)
179
+
180
+ - Fix daily reset of global automation limit so automation never stalls overnight
181
+ - Track latest reset timestamp in safety data for observability
182
+ - Expand safety manager tests to cover daily rollover behaviour
183
+
184
+ ### 0.1.0 (2025-09-28)
185
+
186
+ - Initial release
187
+ - Actionable PR counting system
188
+ - Safety management with dual limits
189
+ - Cross-process file-based persistence
190
+ - Email notification support
191
+ - Comprehensive test suite (200+ tests)
192
+ - CLI interfaces for monitoring and safety management
@@ -0,0 +1,32 @@
1
+ """
2
+ jleechanorg-pr-automation: GitHub PR automation system with safety limits and actionable counting.
3
+
4
+ This package provides comprehensive PR monitoring and automation capabilities with built-in
5
+ safety features, intelligent filtering, and cross-process synchronization.
6
+ """
7
+
8
+ from .jleechanorg_pr_monitor import JleechanorgPRMonitor
9
+ from .automation_safety_manager import AutomationSafetyManager
10
+ from .utils import (
11
+ SafeJSONManager,
12
+ setup_logging,
13
+ get_email_config,
14
+ validate_email_config,
15
+ get_automation_limits,
16
+ json_manager,
17
+ )
18
+
19
+ __version__ = "0.1.1"
20
+ __author__ = "jleechan"
21
+ __email__ = "jlee@jleechan.org"
22
+
23
+ __all__ = [
24
+ "JleechanorgPRMonitor",
25
+ "AutomationSafetyManager",
26
+ "SafeJSONManager",
27
+ "setup_logging",
28
+ "get_email_config",
29
+ "validate_email_config",
30
+ "get_automation_limits",
31
+ "json_manager",
32
+ ]