patchwise 0.2.1__tar.gz → 0.9.2__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.
Files changed (155) hide show
  1. patchwise-0.9.2/PKG-INFO +412 -0
  2. patchwise-0.9.2/README.md +375 -0
  3. patchwise-0.9.2/patchwise/__init__.py +33 -0
  4. patchwise-0.9.2/patchwise/default_config.yaml +54 -0
  5. patchwise-0.9.2/patchwise/docker.py +978 -0
  6. patchwise-0.9.2/patchwise/dockerfiles/AiCodeReview.Dockerfile +13 -0
  7. patchwise-0.9.2/patchwise/dockerfiles/Checkpatch.Dockerfile +10 -0
  8. patchwise-0.9.2/patchwise/dockerfiles/Coccicheck.Dockerfile +13 -0
  9. patchwise-0.9.2/patchwise/dockerfiles/CrashdumpAgent.Dockerfile +12 -0
  10. patchwise-0.9.2/patchwise/dockerfiles/DtCheck.Dockerfile +26 -0
  11. patchwise-0.9.2/patchwise/dockerfiles/DtbsCheck.Dockerfile +37 -0
  12. patchwise-0.9.2/patchwise/dockerfiles/LLMCommitAudit.Dockerfile +9 -0
  13. patchwise-0.9.2/patchwise/dockerfiles/Sparse.Dockerfile +39 -0
  14. patchwise-0.9.2/patchwise/dockerfiles/base.Dockerfile +72 -0
  15. {patchwise-0.2.1 → patchwise-0.9.2}/patchwise/logger_setup.py +3 -2
  16. patchwise-0.9.2/patchwise/mail_handler/ai_models.py +10 -0
  17. patchwise-0.9.2/patchwise/mail_handler/cli.py +115 -0
  18. patchwise-0.9.2/patchwise/mail_handler/config.py +65 -0
  19. patchwise-0.9.2/patchwise/mail_handler/handler.py +498 -0
  20. patchwise-0.9.2/patchwise/mail_handler/mail_client.py +291 -0
  21. patchwise-0.9.2/patchwise/mail_handler/utils.py +55 -0
  22. patchwise-0.9.2/patchwise/main.py +319 -0
  23. patchwise-0.9.2/patchwise/patch_review/__init__.py +265 -0
  24. patchwise-0.9.2/patchwise/patch_review/ai_agent/__init__.py +47 -0
  25. patchwise-0.9.2/patchwise/patch_review/ai_agent/agent.py +1792 -0
  26. patchwise-0.9.2/patchwise/patch_review/ai_agent/crashdump_agent.py +368 -0
  27. patchwise-0.9.2/patchwise/patch_review/ai_agent/tool_definitions.py +583 -0
  28. patchwise-0.9.2/patchwise/patch_review/ai_fix/__init__.py +6 -0
  29. patchwise-0.9.2/patchwise/patch_review/ai_fix/ai_fix.py +109 -0
  30. patchwise-0.9.2/patchwise/patch_review/ai_fix/ai_patch_fix.py +111 -0
  31. patchwise-0.9.2/patchwise/patch_review/ai_fix/checkpatch_fixer.py +688 -0
  32. patchwise-0.9.2/patchwise/patch_review/ai_fix/kernel_docs_rag.py +469 -0
  33. patchwise-0.9.2/patchwise/patch_review/ai_fix/sparse_fixer.py +309 -0
  34. patchwise-0.9.2/patchwise/patch_review/ai_review/ai_code_review.py +1704 -0
  35. patchwise-0.9.2/patchwise/patch_review/ai_review/ai_review.py +199 -0
  36. patchwise-0.9.2/patchwise/patch_review/ai_review/fetch_reviewer_comment.py +375 -0
  37. {patchwise-0.2.1 → patchwise-0.9.2}/patchwise/patch_review/ai_review/llm_commit_audit.py +2 -6
  38. patchwise-0.9.2/patchwise/patch_review/ai_review/root_cause_analysis.py +1314 -0
  39. patchwise-0.9.2/patchwise/patch_review/ai_review/ts_cache.py +92 -0
  40. patchwise-0.9.2/patchwise/patch_review/ai_review/ts_indexer.py +360 -0
  41. {patchwise-0.2.1 → patchwise-0.9.2}/patchwise/patch_review/decorators.py +17 -1
  42. {patchwise-0.2.1 → patchwise-0.9.2}/patchwise/patch_review/kernel_tree.py +38 -2
  43. patchwise-0.9.2/patchwise/patch_review/patch_review.py +103 -0
  44. patchwise-0.9.2/patchwise/patch_review/static_analysis/__init__.py +2 -0
  45. {patchwise-0.2.1 → patchwise-0.9.2}/patchwise/patch_review/static_analysis/checkpatch.py +3 -5
  46. {patchwise-0.2.1 → patchwise-0.9.2}/patchwise/patch_review/static_analysis/coccicheck.py +47 -7
  47. {patchwise-0.2.1 → patchwise-0.9.2}/patchwise/patch_review/static_analysis/dt_check.py +65 -38
  48. patchwise-0.9.2/patchwise/patch_review/static_analysis/dtbs_check.py +115 -0
  49. patchwise-0.9.2/patchwise/patch_review/static_analysis/sparse.py +171 -0
  50. patchwise-0.9.2/patchwise/patch_review/static_analysis/static_analysis.py +134 -0
  51. patchwise-0.9.2/patchwise/stats/__init__.py +4 -0
  52. patchwise-0.9.2/patchwise/stats/dashboard.py +957 -0
  53. patchwise-0.9.2/patchwise/ui/__init__.py +11 -0
  54. patchwise-0.9.2/patchwise/ui/dashboard.py +680 -0
  55. patchwise-0.9.2/patchwise/ui/events.py +72 -0
  56. patchwise-0.9.2/patchwise/ui/screen.py +320 -0
  57. patchwise-0.9.2/patchwise/utils/config.py +70 -0
  58. patchwise-0.9.2/patchwise/utils/decorators.py +102 -0
  59. patchwise-0.9.2/patchwise/utils/lru_cache.py +25 -0
  60. patchwise-0.9.2/patchwise/utils/repo_workspace.py +123 -0
  61. patchwise-0.9.2/patchwise/utils/tui.py +81 -0
  62. patchwise-0.9.2/patchwise.egg-info/PKG-INFO +412 -0
  63. patchwise-0.9.2/patchwise.egg-info/SOURCES.txt +138 -0
  64. patchwise-0.9.2/patchwise.egg-info/requires.txt +24 -0
  65. patchwise-0.9.2/pyproject.toml +67 -0
  66. patchwise-0.9.2/tests/test_mail_handler_series_refs.py +108 -0
  67. patchwise-0.9.2/thirdparty/review-prompts/kernel/false-positive-guide.md +478 -0
  68. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/alignment.md +68 -0
  69. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/arm64.md +529 -0
  70. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/ata.md +75 -0
  71. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/block.md +102 -0
  72. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/bluetooth.md +138 -0
  73. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/boot-params.md +45 -0
  74. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/bpf.md +239 -0
  75. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/btf.md +60 -0
  76. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/btrfs.md +126 -0
  77. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/build.md +29 -0
  78. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/cleanup.md +166 -0
  79. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/cxl.md +37 -0
  80. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/dax.md +25 -0
  81. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/drm.md +889 -0
  82. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/dt-bindings.md +107 -0
  83. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/fscrypt.md +25 -0
  84. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/gic-v3.md +1225 -0
  85. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/gic-v5.md +1027 -0
  86. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/hid.md +395 -0
  87. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/hyp-arm64.md +742 -0
  88. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/i2c.md +99 -0
  89. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/input.md +235 -0
  90. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/io-accessors.md +91 -0
  91. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/io_uring.md +341 -0
  92. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/kconfig.md +104 -0
  93. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/kho.md +121 -0
  94. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/kvm-arm64.md +246 -0
  95. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/kvm.md +304 -0
  96. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/libbpf.md +80 -0
  97. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/locking.md +520 -0
  98. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/mips.md +80 -0
  99. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/mm-alloc.md +319 -0
  100. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/mm-folio.md +349 -0
  101. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/mm-largepage.md +348 -0
  102. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/mm-pagetable.md +444 -0
  103. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/mm-reclaim.md +245 -0
  104. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/mm-vma.md +246 -0
  105. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/netlink.md +109 -0
  106. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/networking-core.md +310 -0
  107. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/networking-drivers.md +147 -0
  108. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/nfsd.md +532 -0
  109. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/objtool.md +57 -0
  110. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/of.md +138 -0
  111. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/pci.md +114 -0
  112. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/perf.md +111 -0
  113. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/pm.md +222 -0
  114. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/pmdomain.md +119 -0
  115. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/rcu.md +94 -0
  116. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/rust.md +54 -0
  117. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/scheduler.md +212 -0
  118. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/selftests.md +314 -0
  119. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/smb-ksmbd.md +67 -0
  120. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/subjective-review.md +44 -0
  121. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/subsystem-template.md +184 -0
  122. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/subsystem.md +95 -0
  123. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/sunrpc.md +344 -0
  124. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/syscall.md +12 -0
  125. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/sysfs.md +130 -0
  126. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/timers.md +105 -0
  127. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/tracing.md +97 -0
  128. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/tty.md +90 -0
  129. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/usb-storage.md +83 -0
  130. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/vfs.md +233 -0
  131. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/wireless.md +73 -0
  132. patchwise-0.9.2/thirdparty/review-prompts/kernel/subsystem/workqueue.md +3 -0
  133. patchwise-0.9.2/thirdparty/review-prompts/kernel/technical-patterns.md +161 -0
  134. patchwise-0.2.1/PKG-INFO +0 -18
  135. patchwise-0.2.1/README.md +0 -172
  136. patchwise-0.2.1/patchwise/__init__.py +0 -18
  137. patchwise-0.2.1/patchwise/main.py +0 -106
  138. patchwise-0.2.1/patchwise/patch_review/__init__.py +0 -170
  139. patchwise-0.2.1/patchwise/patch_review/ai_review/ai_code_review.py +0 -1100
  140. patchwise-0.2.1/patchwise/patch_review/ai_review/ai_review.py +0 -188
  141. patchwise-0.2.1/patchwise/patch_review/patch_review.py +0 -325
  142. patchwise-0.2.1/patchwise/patch_review/static_analysis/dtbs_check.py +0 -91
  143. patchwise-0.2.1/patchwise/patch_review/static_analysis/sparse.py +0 -165
  144. patchwise-0.2.1/patchwise/patch_review/static_analysis/static_analysis.py +0 -54
  145. patchwise-0.2.1/patchwise.egg-info/PKG-INFO +0 -18
  146. patchwise-0.2.1/patchwise.egg-info/SOURCES.txt +0 -27
  147. patchwise-0.2.1/patchwise.egg-info/requires.txt +0 -10
  148. patchwise-0.2.1/pyproject.toml +0 -33
  149. {patchwise-0.2.1 → patchwise-0.9.2}/LICENSE.txt +0 -0
  150. {patchwise-0.2.1/patchwise/patch_review/ai_review → patchwise-0.9.2/patchwise/mail_handler}/__init__.py +0 -0
  151. {patchwise-0.2.1/patchwise/patch_review/static_analysis → patchwise-0.9.2/patchwise/patch_review/ai_review}/__init__.py +0 -0
  152. {patchwise-0.2.1 → patchwise-0.9.2}/patchwise.egg-info/dependency_links.txt +0 -0
  153. {patchwise-0.2.1 → patchwise-0.9.2}/patchwise.egg-info/entry_points.txt +0 -0
  154. {patchwise-0.2.1 → patchwise-0.9.2}/patchwise.egg-info/top_level.txt +0 -0
  155. {patchwise-0.2.1 → patchwise-0.9.2}/setup.cfg +0 -0
@@ -0,0 +1,412 @@
1
+ Metadata-Version: 2.4
2
+ Name: patchwise
3
+ Version: 0.9.2
4
+ Summary: AI Code Review, Root Cause Analysis and Static Analysis for the Linux kernel
5
+ Author-email: "Qualcomm Technologies, Inc." <qc.opensource@qti.qualcomm.com>
6
+ Maintainer-email: Aditya Chillara <achillar@qti.qualcomm.com>
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Programming Language :: Python :: 3.10
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE.txt
12
+ Requires-Dist: Sphinx>=8.1.3
13
+ Requires-Dist: litellm<1.97,>=1.74
14
+ Requires-Dist: cachetools>=5.5.2
15
+ Requires-Dist: chromadb>=0.4.0
16
+ Requires-Dist: yamllint>=1.26.3
17
+ Requires-Dist: ply>=3.11
18
+ Requires-Dist: GitPython>=3.1.44
19
+ Requires-Dist: codespell>=2.4.1
20
+ Requires-Dist: pytest>=8.3.5
21
+ Requires-Dist: rich>=13
22
+ Requires-Dist: rich-argparse>=1.7.0
23
+ Requires-Dist: blessed>=1.20
24
+ Requires-Dist: tqdm>=4.67.1
25
+ Requires-Dist: platformdirs>=4.3.8
26
+ Requires-Dist: requests>=2.31.0
27
+ Requires-Dist: sentence-transformers>=5.6.0
28
+ Requires-Dist: chromadb>=1.5.9
29
+ Requires-Dist: imapclient>=3.0.0
30
+ Requires-Dist: fastapi>=0.110
31
+ Requires-Dist: uvicorn>=0.29
32
+ Requires-Dist: pygments>=2.19.0
33
+ Requires-Dist: redis>=5
34
+ Requires-Dist: tree-sitter>=0.24
35
+ Requires-Dist: tree-sitter-c>=0.23
36
+ Dynamic: license-file
37
+
38
+ # PatchWise
39
+
40
+ [![License](https://img.shields.io/badge/license-BSD--3--Clause-blue.svg)](LICENSE.txt)
41
+ [![Python](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
42
+
43
+ > **PatchWise** automates patch review and static analysis for the Linux kernel, streamlining upstream contributions and ensuring code quality.
44
+
45
+ ---
46
+
47
+ ## Table of Contents
48
+
49
+ - [Features](#features)
50
+ - [Getting Started](#getting-started)
51
+ - [Prerequisites](#prerequisites)
52
+ - [Installation](#installation)
53
+ - [Usage](#usage)
54
+ - [AI Code Review](#ai-code-review)
55
+ - [Crashdump Root-Cause Analysis](#crashdump-root-cause-analysis)
56
+ - [Mail Mode](#mail-mode)
57
+ - [Configuration](#configuration)
58
+ - [Command-Line Options](#command-line-options)
59
+ - [Development](#development)
60
+ - [Getting in Contact](#getting-in-contact)
61
+ - [License](#license)
62
+
63
+ ---
64
+
65
+ ## Features
66
+
67
+ - **Automated Patch Review**: Runs static analysis and style checks on kernel patches.
68
+ - **Integration with Mailing Lists**: Processes patches sent via email and responds automatically.
69
+ - **Flexible Review Selection**: Choose which review checks to run.
70
+ - **Rich Logging**: Colorized and file-based logging for easy debugging.
71
+ - **LLM Integration**: Uses Artificial Intelligence for commit message analysis and suggestions.
72
+ - **AI Code Review**: Leverages artificial intelligence to provide insights on code quality and potential issues. Uses tree-sitter + ripgrep for context-aware code navigation. Support for multiple LLMs and providers, including OpenAI.
73
+ - **Downstream repo(1) Workspace Support**: Reviews patches in `repo(1)`-managed downstream workspaces (e.g. the Android Common Kernel), not just standalone upstream `.git` kernel trees. See [the note on downstream workspaces](#patch-review-options).
74
+ - **Crashdump Root-Cause Analysis** (`--rca`): Root-causes a kernel crashdump folder and proposes a fix.
75
+
76
+ ---
77
+
78
+ ## Getting Started
79
+
80
+ ### Prerequisites
81
+
82
+ - Python 3.10 or newer
83
+ - Access to a Linux kernel git repository
84
+ - Docker installed, with permissions to run Docker commands (PatchWise runs reviews inside Docker containers)
85
+
86
+ ### Installation
87
+
88
+ 1. **Create and activate a virtual environment:**
89
+
90
+ ```bash
91
+ python3.10 -m venv .venv
92
+ source .venv/bin/activate
93
+ ```
94
+
95
+ 1. **Install PatchWise:**
96
+
97
+ ```bash
98
+ pip install patchwise
99
+ ```
100
+
101
+ To install the latest unreleased code from `main` instead:
102
+
103
+ ```bash
104
+ pip install git+https://github.com/qualcomm/PatchWise.git@main
105
+ ```
106
+
107
+ 1. **Set up your API key:**
108
+
109
+ Obtain your API key from your provider and set it as an environment variable:
110
+
111
+ ```bash
112
+ export OPENAI_API_KEY=<your-api-key>
113
+ ```
114
+
115
+ Add this line to your shell profile (e.g., `~/.bashrc` or `~/.zshrc`) for persistence.
116
+
117
+ Alternatively, set `ai.api_key` in `~/.config/patchwise_config.yaml`:
118
+
119
+ ```yaml
120
+ ai:
121
+ api_key: "<your-api-key>"
122
+ ```
123
+
124
+ The `ai:` block also accepts `model`, `provider`, and `reasoning_effort`,
125
+ which set the defaults for the corresponding CLI flags.
126
+
127
+ 1. **Run help message:**
128
+
129
+ ```bash
130
+ patchwise --help
131
+ ```
132
+
133
+ ## Usage
134
+
135
+ 1. **Run PatchWise:**
136
+
137
+ Run PatchWise in the root of your kernel workspace:
138
+
139
+ ```bash
140
+ patchwise
141
+ ```
142
+
143
+ By default, PatchWise will review the `HEAD` commit. Use the `--commits` flag to review a specific commit:
144
+
145
+ ```bash
146
+ patchwise --commits <commit-sha>
147
+ ```
148
+
149
+ To run only short reviews, use:
150
+
151
+ ```bash
152
+ patchwise --short-reviews
153
+ ```
154
+
155
+ To run specific reviews, use the `--reviews` flag:
156
+
157
+ ```bash
158
+ patchwise --reviews AiCodeReview Checkpatch DtCheck
159
+ ```
160
+
161
+ To see available reviews and other options, run:
162
+
163
+ ```bash
164
+ patchwise --help
165
+ ```
166
+
167
+ ### AI Code Review
168
+
169
+ `AiCodeReview` reviews a patch in three phases: **PLAN** (a planner ↔ critic
170
+ loop splits the diff into analysis angles), **EXEC** (a focused reviewer works
171
+ those angles as a checklist against the real code), and **FILTER** (drops
172
+ proven false positives) before rendering the final inline review.
173
+
174
+ ```bash
175
+ patchwise --reviews AiCodeReview
176
+ ```
177
+
178
+ ```mermaid
179
+ flowchart TD
180
+ A["Patch + context"] --> B
181
+
182
+ subgraph PLAN["PLAN"]
183
+ direction TD
184
+ P["Planner"] --> C["Critic"]
185
+ C -->|feedback| P
186
+ end
187
+
188
+ B(( )) --> P
189
+ C -->|converged| D["EXEC\n(focused review)"]
190
+ D --> E["FILTER\n(drop false positives)"]
191
+ E --> F(["Inline review"])
192
+ ```
193
+
194
+ Each phase has its own iteration budget, each overridable via env:
195
+
196
+ | Phase | Default cap | Override env |
197
+ |-------|-------------|---------------|
198
+ | Critic loop | `MAX_PLAN_ITERATIONS = 10` rounds | `PATCHWISE_MAX_PLAN_ITERATIONS` |
199
+ | Critic (per round) | `CRITIC_ITER_CAP = 10` | `PATCHWISE_CRITIC_ITER_CAP` |
200
+ | Execution | `EXEC_ITER_CAP = 100` | `PATCHWISE_EXEC_ITER_CAP` |
201
+ | FP filter | `FP_ITER_CAP = 50` | `PATCHWISE_FP_ITER_CAP` |
202
+
203
+ Artifacts land in `SANDBOX_PATH`:
204
+ `prompt.md`, `plan.json`, `findings.md`, `fp_verdicts.json`,
205
+ `observability.json`.
206
+
207
+ ### Crashdump Root-Cause Analysis
208
+
209
+ Root-cause a kernel crashdump instead of reviewing a patch. Point `--dump` at a
210
+ folder containing the dmesg/console log (and any parser output), and `--repo-path`
211
+ at the kernel source tree the crash came from:
212
+
213
+ ```bash
214
+ patchwise --rca --dump <crashdump-folder> --repo-path <kernel-source>
215
+ ```
216
+
217
+ `--repo-path` can be a standalone upstream `.git` kernel tree or a repo(1)-managed
218
+ downstream workspace (e.g. the Android Common Kernel) — the same workspace types
219
+ `AiCodeReview` supports.
220
+
221
+ An *engineer* agent investigates from the evidence and proposes one root cause and
222
+ one fix (as a diff); a *maintainer* agent then challenges that answer — surfacing
223
+ unstated assumptions, symptom-only fixes, and incorrect causes — until it holds.
224
+ Give the engineer a head start with any debugging you've already done:
225
+
226
+ ```bash
227
+ patchwise --rca --dump <crashdump-folder> --repo-path <kernel-source> \
228
+ --additional-context "perf_fuzzer + cpu-hotplug + stress-ng reproduces this"
229
+ ```
230
+
231
+ Unlike the review pipeline there is **no planner or critic framing the search**:
232
+ the engineer investigates example-free (any up-front failure taxonomy or
233
+ subsystem menu would bound it to the listed classes — overfit), and the knowledge
234
+ base lives on the *maintainer*, which challenges a finished answer instead of
235
+ directing the investigation. While the maintainer refutes, the engineer's **same
236
+ conversation is resumed** (full history retained) with the questions appended, so
237
+ it re-investigates rather than starting over. The engineer's final accepted
238
+ answer is the report.
239
+
240
+ ```mermaid
241
+ flowchart TD
242
+ A["Crashdump"] --> B["Engineer\n(root-cause from evidence)"]
243
+ B -->|"1 root cause + 1 fix"| C["Maintainer\n(challenges the answer)"]
244
+ C -->|refuted, budget remains| B
245
+ C -->|accepted / budget spent| D(["rca_report.md"])
246
+ ```
247
+
248
+ Each role draws from its own iteration/token budget (cumulative across resumes), overridable via env:
249
+
250
+ | Role | Default cap | Override env |
251
+ |------|-------------|---------------|
252
+ | Engineer | `EXEC_ITER_CAP = 500` iters, `ENGINEER_TOKEN_BUDGET = 20M` tokens | `PATCHWISE_EXEC_ITER_CAP`, `PATCHWISE_ENGINEER_TOKEN_BUDGET` |
253
+ | Maintainer | `MAINTAINER_ITER_CAP = 250` iters, `MAINTAINER_TOKEN_BUDGET = 10M` tokens | `PATCHWISE_MAINTAINER_ITER_CAP`, `PATCHWISE_MAINTAINER_TOKEN_BUDGET` |
254
+
255
+ An ambiguous or unparseable maintainer verdict accepts the engineer's answer
256
+ by default. Artifacts land in `SANDBOX_PATH`: `prompt.md`,
257
+ `maintainer_verdicts.json`, `rca_report.md`, `observability.json`.
258
+
259
+ > **Note:** The default sandbox location is `/tmp/patchwise/sandbox`. Override it
260
+ > with `PATCHWISE_SANDBOX_PATH=<path/to/sandbox>`.
261
+
262
+ ### Example Workflow
263
+
264
+ ```bash
265
+ cd linux-next # your kernel workspace, with the patch to review already applied
266
+ patchwise
267
+ ```
268
+
269
+ ### Mail Mode
270
+
271
+ Instead of reviewing local commits, PatchWise can watch a mailbox, review
272
+ patches submitted to a mailing list, and reply with the review results. Enable
273
+ this with `--mail`:
274
+
275
+ > **Note:** Mail mode reviews patches against its own kernel tree (linux-next) in the sandbox
276
+ > (default sandbox path is `/tmp/patchwise/sandbox`, override with `PATCHWISE_SANDBOX_PATH`). It
277
+ > does not use `--repo-path`.
278
+
279
+ ```bash
280
+ # Process unflagged mail once, printing the replies to stdout (does not send)
281
+ patchwise --mail
282
+
283
+ # Actually send the review replies (and flag processed mail)
284
+ patchwise --mail --send
285
+
286
+ # Keep watching the mailbox in a loop
287
+ patchwise --mail --watch
288
+
289
+ # Review a single message by its Message-ID
290
+ patchwise --mail --message-id 20250408-example-v6-1-526c61a207f6@example.com
291
+ ```
292
+
293
+ Mail mode is configured through the `mail:` block of your user config file
294
+ (`~/.config/patchwise_config.yaml`), which is merged over the shipped defaults.
295
+ At minimum, set the mailbox credentials and the senders/lists you accept:
296
+
297
+ ```yaml
298
+ mail:
299
+ email: "you@example.com"
300
+ password: "<app-password>"
301
+ from_email: "PatchWise <you@example.com>"
302
+ accepted_sender_domains: ["example.com"]
303
+ accepted_lists: ["kernel@lists.example.com"]
304
+ always_cc: ["maintainers@example.com"]
305
+ additional_cc: ["kernel@lists.example.com"]
306
+ send_mode: 2
307
+ imap:
308
+ server: "imap.gmail.com"
309
+ port: 993
310
+ ssl: true
311
+ smtp:
312
+ server: "smtp.gmail.com"
313
+ port: 465
314
+ ssl: true
315
+ ```
316
+
317
+ `send_mode` controls who replies are addressed to:
318
+
319
+ - `0`: reply only to `always_cc` entries (falls back to the sender if `always_cc` is empty)
320
+ - `1`: reply to the sender, CC `always_cc`
321
+ - `2`: reply to the sender, CC the original To/Cc recipients (filtered to `accepted_sender_domains`) plus `always_cc` plus `additional_cc`
322
+
323
+ ---
324
+
325
+ ## Configuration
326
+
327
+ PatchWise merges [`patchwise/default_config.yaml`](patchwise/default_config.yaml) (shipped defaults) under `~/.config/patchwise_config.yaml` (user overrides) — see that file for all available options.
328
+
329
+ ## Command-Line Options
330
+
331
+ - `-h`, `--help`: Show help message and exit
332
+ - `--mail`: Run the mail-handler loop instead of reviewing local commits. See [Mail Mode](#mail-mode).
333
+ - `--rca`: Root-cause a kernel crashdump folder instead of reviewing commits. See [Crashdump Root-Cause Analysis](#crashdump-root-cause-analysis).
334
+ - `--plain`: Disable the live dashboard and use plain log output.
335
+ - `--stats`: Serve the observability web dashboard instead of running a review, computed from the artifacts under the sandbox.
336
+ - `--output-dir`: Directory to save the review/RCA results. (default: `/tmp/patchwise/output`, overridable via `PATCHWISE_OUTPUT_PATH`)
337
+
338
+ ### Patch Review Options
339
+
340
+ - `--commits`: Space separated list of commit SHAs/refs, or a single commit range in start..end format. (default: [`HEAD`])
341
+ - `--repo-path`: Path to the workspace root. Must directly contain either `.repo` (a repo(1)-managed downstream workspace, e.g. the Android Common Kernel) or `.git` (a standalone upstream kernel); PatchWise raises otherwise. Uses your current directory if not specified. (default: `$PWD`)
342
+ - `--commit-dir`: Git subtree (has `.git`) holding the commit under review, when `--repo-path` is a broader workspace, e.g. `--repo-path .../kp6.0 --commit-dir kernel_platform/soc-repo`. Relative to `--repo-path` or absolute, and inside it. The agent navigates the whole `--repo-path` while the diff and (for upstream) tree reset use this subtree. Defaults to `--repo-path`.
343
+ - `--reviews`: Space-separated list of reviews to run. (default: all available reviews)
344
+ - `--short-reviews`: Run only short reviews. Overrides `--reviews`.
345
+ - `--install`: Install missing dependencies for the specified reviews. This will not run any reviews, only install dependencies.
346
+ - `--fix`: Output a version of the commit that fixes the reported issues, for reviews that support it (currently `AiCodeReview` and `Checkpatch`).
347
+
348
+ > **Downstream (repo(1)-managed) kernels support `AiCodeReview` only.** This
349
+ > covers workspaces like the Android Common Kernel (ACK). When `--repo-path`
350
+ > is a `.repo` workspace root, PatchWise treats the tree as read-only — the
351
+ > caller is responsible for syncing and checking out the change under review,
352
+ > and PatchWise does not reset, clean, or take ownership of it. Running any
353
+ > other review (static analysis, etc.) against such a tree is undefined.
354
+ > Standalone `.git` kernels (upstream) support the full set of reviews.
355
+ >
356
+ > Because a downstream tree is indexed in place, a large build-artifact tree
357
+ > (e.g. `out/`) can be orders of magnitude bigger than the kernel and make the
358
+ > tree-sitter index slow to build. PatchWise already skips the paths/patterns
359
+ > listed under `indexing.blocklist` in the config (default: `**/out/`,
360
+ > `**/prebuilts/`, `**/external/`, `**/bazel-*/`); add your own build/output
361
+ > directory patterns to that list in `~/.config/patchwise_config.yaml` if
362
+ > indexing is slow for your layout. Patterns follow gitignore-style glob
363
+ > syntax.
364
+
365
+ ### Mail Options (require `--mail`)
366
+
367
+ - `--all`: Search all mail, not just unflagged mail. (default: unflagged only)
368
+ - `--since`: Only process messages on or after this date (ISO 8601, e.g. `YYYY-MM-DD`).
369
+ - `--before`: Only process messages before this date (ISO 8601, e.g. `YYYY-MM-DD`).
370
+ - `--message-id`: Process only messages with the given Message-ID(s).
371
+ - `-w`, `--watch`: Watch for new mail and process it in a loop.
372
+ - `--send` / `--no-send`: Send the review replies, or print them to stdout instead. (default: `--no-send`)
373
+
374
+ ### Ai Review Options
375
+
376
+ - `--model`: Specify the AI model to use for code review. (default: `openai/Pro`).
377
+ - `--provider`: The base URL for the AI model API. (default: `https://api.openai.com/v1`)
378
+ - `--reasoning-effort`: Reasoning-effort hint for reasoning models, e.g. `low`/`medium`/`high`. Unset uses the model default.
379
+ - `--additional-context`: Extra text injected into the review/analysis prompt (e.g. a known reproducer or debugging notes). Shared across review and `--rca` modes.
380
+
381
+ ### Crashdump RCA Options (require `--rca`)
382
+
383
+ - `--rca`: Root-cause a kernel crashdump folder instead of reviewing commits.
384
+ - `--dump`: Path to the crashdump folder (must contain a dmesg/console log).
385
+
386
+ The kernel tree is given with `--repo-path`; `--model`, `--provider`, `--additional-context`, and `--output-dir` are shared with the other modes.
387
+
388
+ ### Logging Options
389
+
390
+ - `--log-level`: Set the logging level. (default: `INFO`)
391
+ - `--log-file`: Path to the log file. (default: `<SANDBOX_PATH>/patchwise.log`, i.e. `/tmp/patchwise/sandbox/patchwise.log` unless `PATCHWISE_SANDBOX_PATH` is set)
392
+
393
+ ## Development
394
+
395
+ If you'd like to develop new features or fix existing issues:
396
+
397
+ - Fork the repository and create a new branch for your changes.
398
+ - Make your changes with clear, descriptive commit messages.
399
+ - Ensure your code follows the project's coding standards and passes all tests.
400
+ - Submit a pull request (PR) with a detailed description of your changes to pull your changes into the staging branch in the main repository.
401
+
402
+ Please make sure to follow our contribution guidelines before submitting a pull request. [CONTRIBUTING.md](CONTRIBUTING.md)
403
+
404
+ ## Getting in Contact
405
+
406
+ - [Report an Issue on GitHub](../../issues/new/choose)
407
+ - [Open a Discussion on GitHub](../../discussions/new/choose)
408
+ - [E-mail us](mailto:Maintainers.PatchWise@qualcomm.com,achillar@qti.qualcomm.com) for general questions
409
+
410
+ ## License
411
+
412
+ PatchWise is licensed under the BSD-3-clause License. See [LICENSE.txt](LICENSE.txt) for the full license text.