patchwise 0.9.3__tar.gz → 0.9.4__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 (143) hide show
  1. {patchwise-0.9.3 → patchwise-0.9.4}/PKG-INFO +12 -7
  2. {patchwise-0.9.3 → patchwise-0.9.4}/README.md +10 -5
  3. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/docker.py +77 -153
  4. patchwise-0.9.4/patchwise/dockerfiles/CrashdumpAgent.Dockerfile +22 -0
  5. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/dockerfiles/base.Dockerfile +0 -13
  6. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/mail_handler/cli.py +6 -1
  7. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/mail_handler/handler.py +24 -8
  8. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/mail_handler/mail_client.py +59 -15
  9. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/main.py +11 -0
  10. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/ai_agent/agent.py +107 -50
  11. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/ai_agent/tool_definitions.py +68 -25
  12. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/ai_review/ai_code_review.py +129 -213
  13. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/ai_review/llm_commit_audit.py +1 -1
  14. patchwise-0.9.4/patchwise/patch_review/ai_review/review_prompts.py +60 -0
  15. patchwise-0.9.4/patchwise/patch_review/ai_review/root_cause_analysis.py +889 -0
  16. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/patch_review.py +2 -4
  17. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/ui/dashboard.py +8 -2
  18. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/ui/events.py +1 -0
  19. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise.egg-info/PKG-INFO +12 -7
  20. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise.egg-info/SOURCES.txt +1 -1
  21. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise.egg-info/requires.txt +1 -1
  22. {patchwise-0.9.3 → patchwise-0.9.4}/pyproject.toml +2 -2
  23. {patchwise-0.9.3 → patchwise-0.9.4}/tests/test_mail_handler_series_refs.py +97 -0
  24. patchwise-0.9.3/patchwise/dockerfiles/CrashdumpAgent.Dockerfile +0 -12
  25. patchwise-0.9.3/patchwise/patch_review/ai_agent/crashdump_agent.py +0 -368
  26. patchwise-0.9.3/patchwise/patch_review/ai_review/root_cause_analysis.py +0 -1314
  27. {patchwise-0.9.3 → patchwise-0.9.4}/LICENSE.txt +0 -0
  28. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/__init__.py +0 -0
  29. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/default_config.yaml +0 -0
  30. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/dockerfiles/AiCodeReview.Dockerfile +0 -0
  31. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/dockerfiles/Checkpatch.Dockerfile +0 -0
  32. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/dockerfiles/Coccicheck.Dockerfile +0 -0
  33. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/dockerfiles/DtCheck.Dockerfile +0 -0
  34. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/dockerfiles/DtbsCheck.Dockerfile +0 -0
  35. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/dockerfiles/LLMCommitAudit.Dockerfile +0 -0
  36. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/dockerfiles/Sparse.Dockerfile +0 -0
  37. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/logger_setup.py +0 -0
  38. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/mail_handler/__init__.py +0 -0
  39. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/mail_handler/ai_models.py +0 -0
  40. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/mail_handler/config.py +0 -0
  41. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/mail_handler/utils.py +0 -0
  42. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/__init__.py +0 -0
  43. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/ai_agent/__init__.py +0 -0
  44. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/ai_fix/__init__.py +0 -0
  45. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/ai_fix/ai_fix.py +0 -0
  46. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/ai_fix/ai_patch_fix.py +0 -0
  47. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/ai_fix/checkpatch_fixer.py +0 -0
  48. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/ai_fix/kernel_docs_rag.py +0 -0
  49. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/ai_fix/sparse_fixer.py +0 -0
  50. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/ai_review/__init__.py +0 -0
  51. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/ai_review/ai_review.py +0 -0
  52. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/ai_review/fetch_reviewer_comment.py +0 -0
  53. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/ai_review/ts_cache.py +0 -0
  54. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/ai_review/ts_indexer.py +0 -0
  55. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/decorators.py +0 -0
  56. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/kernel_tree.py +0 -0
  57. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/static_analysis/__init__.py +0 -0
  58. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/static_analysis/checkpatch.py +0 -0
  59. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/static_analysis/coccicheck.py +0 -0
  60. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/static_analysis/dt_check.py +0 -0
  61. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/static_analysis/dtbs_check.py +0 -0
  62. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/static_analysis/sparse.py +0 -0
  63. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/patch_review/static_analysis/static_analysis.py +0 -0
  64. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/stats/__init__.py +0 -0
  65. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/stats/dashboard.py +0 -0
  66. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/ui/__init__.py +0 -0
  67. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/ui/screen.py +0 -0
  68. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/utils/config.py +0 -0
  69. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/utils/decorators.py +0 -0
  70. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/utils/lru_cache.py +0 -0
  71. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/utils/repo_workspace.py +0 -0
  72. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise/utils/tui.py +0 -0
  73. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise.egg-info/dependency_links.txt +0 -0
  74. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise.egg-info/entry_points.txt +0 -0
  75. {patchwise-0.9.3 → patchwise-0.9.4}/patchwise.egg-info/top_level.txt +0 -0
  76. {patchwise-0.9.3 → patchwise-0.9.4}/setup.cfg +0 -0
  77. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/false-positive-guide.md +0 -0
  78. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/alignment.md +0 -0
  79. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/arm64.md +0 -0
  80. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/ata.md +0 -0
  81. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/block.md +0 -0
  82. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/bluetooth.md +0 -0
  83. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/boot-params.md +0 -0
  84. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/bpf.md +0 -0
  85. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/btf.md +0 -0
  86. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/btrfs.md +0 -0
  87. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/build.md +0 -0
  88. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/cleanup.md +0 -0
  89. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/cxl.md +0 -0
  90. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/dax.md +0 -0
  91. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/drm.md +0 -0
  92. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/dt-bindings.md +0 -0
  93. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/fscrypt.md +0 -0
  94. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/gic-v3.md +0 -0
  95. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/gic-v5.md +0 -0
  96. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/hid.md +0 -0
  97. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/hyp-arm64.md +0 -0
  98. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/i2c.md +0 -0
  99. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/input.md +0 -0
  100. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/io-accessors.md +0 -0
  101. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/io_uring.md +0 -0
  102. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/kconfig.md +0 -0
  103. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/kho.md +0 -0
  104. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/kvm-arm64.md +0 -0
  105. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/kvm.md +0 -0
  106. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/libbpf.md +0 -0
  107. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/locking.md +0 -0
  108. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/mips.md +0 -0
  109. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/mm-alloc.md +0 -0
  110. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/mm-folio.md +0 -0
  111. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/mm-largepage.md +0 -0
  112. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/mm-pagetable.md +0 -0
  113. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/mm-reclaim.md +0 -0
  114. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/mm-vma.md +0 -0
  115. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/netlink.md +0 -0
  116. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/networking-core.md +0 -0
  117. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/networking-drivers.md +0 -0
  118. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/nfsd.md +0 -0
  119. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/objtool.md +0 -0
  120. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/of.md +0 -0
  121. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/pci.md +0 -0
  122. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/perf.md +0 -0
  123. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/pm.md +0 -0
  124. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/pmdomain.md +0 -0
  125. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/rcu.md +0 -0
  126. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/rust.md +0 -0
  127. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/scheduler.md +0 -0
  128. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/selftests.md +0 -0
  129. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/smb-ksmbd.md +0 -0
  130. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/subjective-review.md +0 -0
  131. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/subsystem-template.md +0 -0
  132. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/subsystem.md +0 -0
  133. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/sunrpc.md +0 -0
  134. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/syscall.md +0 -0
  135. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/sysfs.md +0 -0
  136. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/timers.md +0 -0
  137. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/tracing.md +0 -0
  138. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/tty.md +0 -0
  139. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/usb-storage.md +0 -0
  140. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/vfs.md +0 -0
  141. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/wireless.md +0 -0
  142. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/subsystem/workqueue.md +0 -0
  143. {patchwise-0.9.3 → patchwise-0.9.4}/thirdparty/review-prompts/kernel/technical-patterns.md +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: patchwise
3
- Version: 0.9.3
3
+ Version: 0.9.4
4
4
  Summary: AI Code Review, Root Cause Analysis and Static Analysis for the Linux kernel
5
5
  Author-email: "Qualcomm Technologies, Inc." <qc.opensource@qti.qualcomm.com>
6
6
  Maintainer-email: Aditya Chillara <achillar@qti.qualcomm.com>
@@ -10,7 +10,7 @@ Requires-Python: >=3.10
10
10
  Description-Content-Type: text/markdown
11
11
  License-File: LICENSE.txt
12
12
  Requires-Dist: Sphinx>=8.1.3
13
- Requires-Dist: litellm<1.97,>=1.74
13
+ Requires-Dist: litellm<=1.105.4,>=1.74
14
14
  Requires-Dist: cachetools>=5.5.2
15
15
  Requires-Dist: chromadb>=0.4.0
16
16
  Requires-Dist: yamllint>=1.26.3
@@ -208,10 +208,13 @@ Artifacts land in `SANDBOX_PATH`:
208
208
 
209
209
  Root-cause a kernel crashdump instead of reviewing a patch. Point `--dump` at a
210
210
  folder containing the dmesg/console log (and any parser output), and `--repo-path`
211
- at the kernel source tree the crash came from:
211
+ at the kernel source tree the crash came from. Optionally pass `--build` with the
212
+ kernel build output (including `vmlinux` and any modules); supplied dump/build
213
+ directories are bind-mounted read-only into the RCA container:
212
214
 
213
215
  ```bash
214
- patchwise --rca --dump <crashdump-folder> --repo-path <kernel-source>
216
+ patchwise --rca --dump <crashdump-folder> --build <kernel-build-output> \
217
+ --repo-path <kernel-source>
215
218
  ```
216
219
 
217
220
  `--repo-path` can be a standalone upstream `.git` kernel tree or a repo(1)-managed
@@ -224,7 +227,8 @@ unstated assumptions, symptom-only fixes, and incorrect causes — until it hold
224
227
  Give the engineer a head start with any debugging you've already done:
225
228
 
226
229
  ```bash
227
- patchwise --rca --dump <crashdump-folder> --repo-path <kernel-source> \
230
+ patchwise --rca --dump <crashdump-folder> --build <kernel-build-output> \
231
+ --repo-path <kernel-source> \
228
232
  --additional-context "perf_fuzzer + cpu-hotplug + stress-ng reproduces this"
229
233
  ```
230
234
 
@@ -242,7 +246,7 @@ flowchart TD
242
246
  A["Crashdump"] --> B["Engineer\n(root-cause from evidence)"]
243
247
  B -->|"1 root cause + 1 fix"| C["Maintainer\n(challenges the answer)"]
244
248
  C -->|refuted, budget remains| B
245
- C -->|accepted / budget spent| D(["rca_report.md"])
249
+ C -->|accepted / budget spent| D(["rca_report_YYYYMMDD_HHMMSS_MICROS.md"])
246
250
  ```
247
251
 
248
252
  Each role draws from its own iteration/token budget (cumulative across resumes), overridable via env:
@@ -381,7 +385,8 @@ PatchWise merges [`patchwise/default_config.yaml`](patchwise/default_config.yaml
381
385
  ### Crashdump RCA Options (require `--rca`)
382
386
 
383
387
  - `--rca`: Root-cause a kernel crashdump folder instead of reviewing commits.
384
- - `--dump`: Path to the crashdump folder (must contain a dmesg/console log).
388
+ - `--dump`: Local path to the crashdump folder (mount network shares first).
389
+ - `--build`: Optional local path to the kernel build output, including `vmlinux` and modules.
385
390
 
386
391
  The kernel tree is given with `--repo-path`; `--model`, `--provider`, `--additional-context`, and `--output-dir` are shared with the other modes.
387
392
 
@@ -171,10 +171,13 @@ Artifacts land in `SANDBOX_PATH`:
171
171
 
172
172
  Root-cause a kernel crashdump instead of reviewing a patch. Point `--dump` at a
173
173
  folder containing the dmesg/console log (and any parser output), and `--repo-path`
174
- at the kernel source tree the crash came from:
174
+ at the kernel source tree the crash came from. Optionally pass `--build` with the
175
+ kernel build output (including `vmlinux` and any modules); supplied dump/build
176
+ directories are bind-mounted read-only into the RCA container:
175
177
 
176
178
  ```bash
177
- patchwise --rca --dump <crashdump-folder> --repo-path <kernel-source>
179
+ patchwise --rca --dump <crashdump-folder> --build <kernel-build-output> \
180
+ --repo-path <kernel-source>
178
181
  ```
179
182
 
180
183
  `--repo-path` can be a standalone upstream `.git` kernel tree or a repo(1)-managed
@@ -187,7 +190,8 @@ unstated assumptions, symptom-only fixes, and incorrect causes — until it hold
187
190
  Give the engineer a head start with any debugging you've already done:
188
191
 
189
192
  ```bash
190
- patchwise --rca --dump <crashdump-folder> --repo-path <kernel-source> \
193
+ patchwise --rca --dump <crashdump-folder> --build <kernel-build-output> \
194
+ --repo-path <kernel-source> \
191
195
  --additional-context "perf_fuzzer + cpu-hotplug + stress-ng reproduces this"
192
196
  ```
193
197
 
@@ -205,7 +209,7 @@ flowchart TD
205
209
  A["Crashdump"] --> B["Engineer\n(root-cause from evidence)"]
206
210
  B -->|"1 root cause + 1 fix"| C["Maintainer\n(challenges the answer)"]
207
211
  C -->|refuted, budget remains| B
208
- C -->|accepted / budget spent| D(["rca_report.md"])
212
+ C -->|accepted / budget spent| D(["rca_report_YYYYMMDD_HHMMSS_MICROS.md"])
209
213
  ```
210
214
 
211
215
  Each role draws from its own iteration/token budget (cumulative across resumes), overridable via env:
@@ -344,7 +348,8 @@ PatchWise merges [`patchwise/default_config.yaml`](patchwise/default_config.yaml
344
348
  ### Crashdump RCA Options (require `--rca`)
345
349
 
346
350
  - `--rca`: Root-cause a kernel crashdump folder instead of reviewing commits.
347
- - `--dump`: Path to the crashdump folder (must contain a dmesg/console log).
351
+ - `--dump`: Local path to the crashdump folder (mount network shares first).
352
+ - `--build`: Optional local path to the kernel build output, including `vmlinux` and modules.
348
353
 
349
354
  The kernel tree is given with `--repo-path`; `--model`, `--provider`, `--additional-context`, and `--output-dir` are shared with the other modes.
350
355
 
@@ -43,6 +43,9 @@ class DockerManager:
43
43
  # Class-level tracking for initialization
44
44
  build_volume_initialized = False
45
45
  _build_volume_name = "patchwise-shared-build"
46
+ sandbox_path = Path("/home") / PACKAGE_NAME
47
+ build_dir = sandbox_path / "build"
48
+ kernel_dir = sandbox_path / "kernel"
46
49
 
47
50
  # Nothing we run in a container needs network (packages are installed at image
48
51
  # build time), and the agent runs model-composed shell commands over an
@@ -76,9 +79,6 @@ class DockerManager:
76
79
  # kernel_platform --project common`). Empty => the mount root is the git
77
80
  # tree (the common case), so existing callers are unchanged.
78
81
  self.git_subdir = (git_subdir or "").strip("/")
79
- self.sandbox_path = Path("/home") / PACKAGE_NAME
80
- self.build_dir = self.sandbox_path / "build"
81
- self.kernel_dir = self.sandbox_path / "kernel"
82
82
  self._kernel_overlay_volume: Optional[str] = None
83
83
  require_workspace_root(str(self.repo_path))
84
84
  self._repo_managed = is_repo_managed(str(self.repo_path))
@@ -122,7 +122,7 @@ class DockerManager:
122
122
  subprocess.run(["docker", "volume", "rm", "-f", vol], capture_output=True)
123
123
 
124
124
  # Create the backing volume that will hold upper/ and work/.
125
- self.logger.info(
125
+ self.logger.debug(
126
126
  f"Creating kernel overlay backing volume '{backing_volume}' "
127
127
  f"for {self.container_name}..."
128
128
  )
@@ -172,7 +172,7 @@ class DockerManager:
172
172
  upper = f"{backing_mountpoint}/upper"
173
173
  work = f"{backing_mountpoint}/work"
174
174
 
175
- self.logger.info(
175
+ self.logger.debug(
176
176
  f"Creating kernel overlay volume '{volume_name}' for {self.container_name}..."
177
177
  )
178
178
  subprocess.run(
@@ -193,7 +193,7 @@ class DockerManager:
193
193
  check=True,
194
194
  capture_output=True,
195
195
  )
196
- self.logger.info(f"Kernel overlay volume '{volume_name}' created.")
196
+ self.logger.debug(f"Kernel overlay volume '{volume_name}' created.")
197
197
  return volume_name
198
198
 
199
199
  def _cleanup_kernel_overlay(self) -> None:
@@ -262,8 +262,13 @@ class DockerManager:
262
262
  f"Tool-specific image {self.image_tag} built successfully."
263
263
  )
264
264
 
265
- def start_container(self, build_path: Path) -> None:
266
- """Legacy method for backward compatibility. Use start_container_with_shared_volume instead."""
265
+ def _start_container(
266
+ self,
267
+ mounts: list[str],
268
+ *,
269
+ reset_tree: bool = True,
270
+ ) -> None:
271
+ """Start a container and run the common post-start preparation."""
267
272
  try:
268
273
  self._kernel_overlay_volume = self._setup_kernel_overlay()
269
274
  except subprocess.CalledProcessError as e:
@@ -279,6 +284,10 @@ class DockerManager:
279
284
  ["docker", "rm", "-f", self.container_name],
280
285
  capture_output=True,
281
286
  )
287
+ overlay = self._kernel_overlay_volume
288
+ if overlay is None:
289
+ raise RuntimeError("kernel overlay volume was not created")
290
+ mounts = [*mounts, f"{overlay}:{self.kernel_dir}"]
282
291
  args = [
283
292
  "docker",
284
293
  "run",
@@ -286,18 +295,11 @@ class DockerManager:
286
295
  "--name",
287
296
  self.container_name,
288
297
  *self._NETWORK_ARGS,
289
- "-v",
290
- f"{build_path}:{self.build_dir}",
291
- "-v",
292
- f"{self._kernel_overlay_volume}:{self.kernel_dir}",
293
- self.image_tag,
294
- "tail",
295
- "-f",
296
- "/dev/null",
297
298
  ]
298
- self.logger.info(
299
- f"Starting container {self.container_name} with args {' '.join(args)}..."
300
- )
299
+ for mount in mounts:
300
+ args += ["-v", mount]
301
+ args += [self.image_tag, "tail", "-f", "/dev/null"]
302
+ self.logger.info(f"Starting container {self.container_name}...")
301
303
  try:
302
304
  subprocess.run(
303
305
  args,
@@ -322,7 +324,7 @@ class DockerManager:
322
324
  raise
323
325
 
324
326
  try:
325
- self._prepare_kernel_tree()
327
+ self._prepare_kernel_tree(reset_tree=reset_tree)
326
328
  except subprocess.CalledProcessError as e:
327
329
  self.logger.error(
328
330
  f"Failed to prepare kernel tree at {self.commit_sha}: {e}\nstderr: {e.stderr}"
@@ -330,6 +332,37 @@ class DockerManager:
330
332
  self._cleanup_kernel_overlay()
331
333
  raise
332
334
 
335
+ def start_container(
336
+ self,
337
+ mounts: dict[Path, str] = {},
338
+ *,
339
+ mount_shared_build: bool = True,
340
+ reset_tree: bool = True,
341
+ ) -> None:
342
+ """Start a container with caller-selected mounts.
343
+
344
+ Mount destinations may include Docker options, such as ``:ro``.
345
+ """
346
+ docker_mounts = []
347
+ if mount_shared_build:
348
+ docker_mounts.append(f"{self._build_volume_name}:{self.build_dir}")
349
+ docker_mounts.extend(f"{host}:{dest}" for host, dest in mounts.items())
350
+
351
+ # Don't reset repo-managed trees; simply assume review-ready
352
+ if self._repo_managed:
353
+ reset_tree = False
354
+ self._start_container(docker_mounts, reset_tree=reset_tree)
355
+
356
+ if mount_shared_build:
357
+ try:
358
+ self._fix_build_directory_permissions()
359
+ except subprocess.CalledProcessError as e:
360
+ self.logger.error(
361
+ f"Failed to fix build directory permissions: {e}\nstderr: {e.stderr}"
362
+ )
363
+ self._cleanup_kernel_overlay()
364
+ raise
365
+
333
366
  def run_command(
334
367
  self, command: list[str], cwd: Optional[str], **kwargs: Any
335
368
  ) -> subprocess.Popen[str]:
@@ -505,13 +538,13 @@ class DockerManager:
505
538
  return
506
539
  except subprocess.CalledProcessError:
507
540
  # Volume doesn't exist, create it
508
- logger.info(f"Creating shared build volume {cls._build_volume_name}...")
541
+ logger.debug(f"Creating shared build volume {cls._build_volume_name}...")
509
542
  subprocess.run(
510
543
  ["docker", "volume", "create", cls._build_volume_name],
511
544
  check=True,
512
545
  capture_output=True,
513
546
  )
514
- logger.info(f"Volume {cls._build_volume_name} created successfully.")
547
+ logger.debug(f"Volume {cls._build_volume_name} created successfully.")
515
548
 
516
549
  @classmethod
517
550
  def initialize_shared_build_volume(
@@ -524,7 +557,7 @@ class DockerManager:
524
557
  logger.debug("Build volume already initialized, skipping.")
525
558
  return
526
559
 
527
- logger.info("Initializing shared build volume...")
560
+ logger.debug("Initializing shared build volume...")
528
561
 
529
562
  # Ensure the volume exists
530
563
  cls.create_shared_build_volume()
@@ -544,7 +577,7 @@ class DockerManager:
544
577
  init_container_name,
545
578
  *cls._NETWORK_ARGS,
546
579
  "-v",
547
- f"{cls._build_volume_name}:/shared/build",
580
+ f"{cls._build_volume_name}:{cls.build_dir}",
548
581
  base_image_tag,
549
582
  "tail",
550
583
  "-f",
@@ -568,9 +601,9 @@ class DockerManager:
568
601
  (
569
602
  "set -e; "
570
603
  "echo 'Initializing shared build directory...'; "
571
- "mkdir -p /shared/build; "
572
- "chown -R patchwise:patchwise /shared/build; "
573
- "chmod -R 755 /shared/build; "
604
+ f"mkdir -p {cls.build_dir}; "
605
+ f"chown -R patchwise:patchwise {cls.build_dir}; "
606
+ f"chmod -R 755 {cls.build_dir}; "
574
607
  "echo 'Build directory initialized successfully'"
575
608
  ),
576
609
  ],
@@ -578,7 +611,7 @@ class DockerManager:
578
611
  capture_output=True,
579
612
  )
580
613
 
581
- logger.info("Shared build volume initialized successfully.")
614
+ logger.debug("Shared build volume initialized successfully.")
582
615
  cls.build_volume_initialized = True
583
616
 
584
617
  finally:
@@ -635,7 +668,7 @@ class DockerManager:
635
668
  cls.ts_cache_initialized = True
636
669
  return
637
670
  # Exists but stopped — restart it rather than recreate (name is taken).
638
- logger.info(
671
+ logger.debug(
639
672
  f"Restarting stopped ts-cache container {cls._ts_cache_container}..."
640
673
  )
641
674
  subprocess.run(
@@ -647,7 +680,7 @@ class DockerManager:
647
680
  cls.ts_cache_initialized = True
648
681
  return
649
682
 
650
- logger.info(f"Starting ts-cache container {cls._ts_cache_container}...")
683
+ logger.debug(f"Starting ts-cache container {cls._ts_cache_container}...")
651
684
  host, port = redis_address()
652
685
  subprocess.run(
653
686
  [
@@ -675,7 +708,7 @@ class DockerManager:
675
708
  capture_output=True,
676
709
  )
677
710
  cls._wait_ts_cache_ready()
678
- logger.info(f"ts-cache container {cls._ts_cache_container} started.")
711
+ logger.debug(f"ts-cache container {cls._ts_cache_container} started.")
679
712
  cls.ts_cache_initialized = True
680
713
 
681
714
  @classmethod
@@ -698,140 +731,34 @@ class DockerManager:
698
731
  )
699
732
  time.sleep(1)
700
733
 
701
- def start_container_with_shared_volume(self) -> None:
702
- """Start container with the shared build volume instead of bind mount."""
703
- try:
704
- self._kernel_overlay_volume = self._setup_kernel_overlay()
705
- except subprocess.CalledProcessError as e:
706
- self.logger.error(
707
- f"Failed to create kernel overlay volume: {e}\nstderr:{e.stderr}"
708
- )
709
- raise
710
-
711
- # Always remove any existing container (running or stopped) with this
712
- # name and start fresh, so a stale container from a crashed run can
713
- # never be reused or block `docker run` on the name.
714
- subprocess.run(
715
- ["docker", "rm", "-f", self.container_name],
716
- capture_output=True,
717
- )
718
- args = [
719
- "docker",
720
- "run",
721
- "-d",
722
- "--name",
723
- self.container_name,
724
- *self._NETWORK_ARGS,
725
- "-v",
726
- f"{self._build_volume_name}:/shared/build",
727
- "-v",
728
- f"{self._build_volume_name}:{self.build_dir}",
729
- "-v",
730
- f"{self._kernel_overlay_volume}:{self.kernel_dir}",
731
- ]
732
- args += [
733
- self.image_tag,
734
- "tail",
735
- "-f",
736
- "/dev/null",
737
- ]
738
- self.logger.info(
739
- f"Starting container {self.container_name} with shared volume..."
740
- )
741
- try:
742
- subprocess.run(
743
- args,
744
- check=True,
745
- capture_output=True,
746
- )
747
- except subprocess.CalledProcessError as e:
748
- self.logger.error(
749
- f"Failed to start container {self.container_name}: {e}\nstderr: {e.stderr}"
750
- )
751
- self._cleanup_kernel_overlay()
752
- raise
753
- self.logger.info(f"Container {self.container_name} started successfully.")
754
-
755
- # Ensure the specific build directory has proper permissions
756
- try:
757
- self._fix_build_directory_permissions()
758
- except subprocess.CalledProcessError as e:
759
- self.logger.error(
760
- f"Failed to fix build directory permissions: {e}\nstderr: {e.stderr}"
761
- )
762
- self._cleanup_kernel_overlay()
763
- raise
764
-
765
- try:
766
- self._configure_git_identity()
767
- except subprocess.CalledProcessError as e:
768
- self.logger.error(
769
- f"Failed to configure git identity: {e}\nstderr: {e.stderr}"
770
- )
771
- self._cleanup_kernel_overlay()
772
- raise
773
-
774
- try:
775
- self._prepare_kernel_tree()
776
- except subprocess.CalledProcessError as e:
777
- self.logger.error(
778
- f"Failed to prepare kernel tree at {self.commit_sha}: {e}\nstderr: {e.stderr}"
779
- )
780
- self._cleanup_kernel_overlay()
781
- raise
782
-
783
- def _prepare_kernel_tree(self) -> None:
784
- """Configure git trust and, for standalone (upstream) kernels, reset the
785
- tree to the commit under review.
786
-
787
- Skipped for downstream repo(1) workspaces: the caller already checked out
788
- the change and only the read-only AiCodeReview runs. (The tree is an
789
- overlay, so reset/clean/chown never reach the caller's on-disk tree.)"""
734
+ def _prepare_kernel_tree(self, *, reset_tree: bool = True) -> None:
735
+ """Configure Git trust and optionally reset the tree under review."""
790
736
  self.logger.debug(
791
737
  f"Preparing kernel tree at {self.commit_sha} in {self.container_name}..."
792
738
  )
739
+
740
+ # Trust all repositories for Git commands in the container
793
741
  subprocess.run(
794
742
  [
795
743
  "docker",
796
744
  "exec",
797
745
  "--user",
798
746
  "root",
799
- "--workdir",
800
- self._git_workdir,
801
747
  self.container_name,
802
748
  "git",
803
749
  "config",
804
- "--global",
750
+ "--system",
805
751
  "--add",
806
752
  "safe.directory",
807
- self._git_workdir,
753
+ "*",
808
754
  ],
809
755
  check=True,
810
756
  capture_output=True,
811
757
  )
812
758
 
813
- # Downstream: the tree is left as mounted (foreign-owned, never chowned)
814
- # and git runs as the agent user across projects, so trust every store.
815
- if self._repo_managed:
816
- subprocess.run(
817
- [
818
- "docker",
819
- "exec",
820
- "--user",
821
- "root",
822
- self.container_name,
823
- "git",
824
- "config",
825
- "--system",
826
- "--add",
827
- "safe.directory",
828
- "*",
829
- ],
830
- check=True,
831
- capture_output=True,
832
- )
759
+ if not reset_tree:
833
760
  self.logger.debug(
834
- "repo-managed workspace: leaving tree as mounted (read-only)."
761
+ "leaving the kernel tree as mounted without resetting it."
835
762
  )
836
763
  return
837
764
 
@@ -868,11 +795,8 @@ class DockerManager:
868
795
  check=True,
869
796
  capture_output=True,
870
797
  )
871
- # Give the agent ownership of the git tree (where git wrote during reset).
872
- # Only the project subtree is chown'd, not the whole mount: when repo_path
873
- # is a broad workspace, recursively chowning every sibling project would be
874
- # huge and pointless — kernel source is world-readable, so the agent reads
875
- # siblings (e.g. out-of-tree modules) without owning them.
798
+ # Give the agent ownership of the git tree (where git wrote during reset)
799
+ # TODO: Does resetting outside the container in --mail mode avoid this?
876
800
  subprocess.run(
877
801
  [
878
802
  "docker",
@@ -933,7 +857,7 @@ class DockerManager:
933
857
  self.container_name,
934
858
  "mkdir",
935
859
  "-p",
936
- f"/shared/build/{self.commit_sha}",
860
+ str(self.build_dir / self.commit_sha),
937
861
  ],
938
862
  check=True,
939
863
  capture_output=True,
@@ -949,7 +873,7 @@ class DockerManager:
949
873
  "chown",
950
874
  "-R",
951
875
  "patchwise:patchwise",
952
- f"/shared/build/{self.commit_sha}",
876
+ str(self.build_dir / self.commit_sha),
953
877
  ],
954
878
  check=True,
955
879
  capture_output=True,
@@ -965,7 +889,7 @@ class DockerManager:
965
889
  "chmod",
966
890
  "-R",
967
891
  "755",
968
- f"/shared/build/{self.commit_sha}",
892
+ str(self.build_dir / self.commit_sha),
969
893
  ],
970
894
  check=True,
971
895
  capture_output=True,
@@ -0,0 +1,22 @@
1
+ # Inherit from the base image
2
+ FROM patchwise-base:latest
3
+
4
+ USER root
5
+
6
+ # Dump analysis tools, all work on any target architecture
7
+ RUN apt-get update && apt-get install -y --no-install-recommends \
8
+ ripgrep \
9
+ jq \
10
+ file \
11
+ xz-utils \
12
+ zstd \
13
+ gdb-multiarch \
14
+ dwarves \
15
+ && rm -rf /var/lib/apt/lists/*
16
+
17
+ RUN pip3 install "pathspec>=0.12" pyelftools
18
+
19
+ # Scratch space for the agent
20
+ RUN mkdir /work && chown patchwise:patchwise /work
21
+
22
+ USER patchwise
@@ -56,17 +56,4 @@ RUN mkdir /home/patchwise/build && chown -R patchwise:patchwise /home/patchwise/
56
56
  RUN python3 -m venv /home/patchwise/.venv
57
57
  ENV PATH="/home/patchwise/.venv/bin:$PATH"
58
58
 
59
- # Create initialization script for shared build directory
60
- COPY <<EOF /home/patchwise/init-build-dir.sh
61
- #!/bin/bash
62
- set -e
63
- echo "Initializing shared build directory..."
64
- mkdir -p /shared/build
65
- chown -R patchwise:patchwise /shared/build
66
- chmod -R 755 /shared/build
67
- echo "Build directory initialized successfully"
68
- EOF
69
-
70
- RUN chmod +x /home/patchwise/init-build-dir.sh
71
-
72
59
  USER patchwise
@@ -11,6 +11,7 @@ from typing import Set
11
11
 
12
12
  from patchwise.mail_handler.config import MailConfig
13
13
  from patchwise.mail_handler.handler import process_mail
14
+ from patchwise.mail_handler.mail_client import MailClient
14
15
  from patchwise.patch_review import get_selected_reviews_from_args
15
16
 
16
17
  logger = logging.getLogger(__name__)
@@ -93,9 +94,13 @@ def _process_loop(
93
94
  fix: bool,
94
95
  ) -> None:
95
96
  """Process mail in a loop or once based on the watch flag."""
97
+ logger.info(f"IMAP: {config.imap.server}:{config.imap.port}")
98
+ logger.info(f"SMTP: {config.smtp.server}:{config.smtp.port}")
99
+ # One IMAP session for the whole run
100
+ mail_client = MailClient(config, send=send)
96
101
  try:
97
102
  while True:
98
- process_mail(criteria, reviews, config, send=send, fix=fix)
103
+ process_mail(mail_client, criteria, reviews, config, fix=fix)
99
104
 
100
105
  if watch:
101
106
  logger.info(f"Sleeping for {WATCH_INTERVAL}")
@@ -39,6 +39,18 @@ logger = logging.getLogger("patchwise.mail_handler.handler")
39
39
  KERNEL_TREE = os.path.join(SANDBOX_PATH, "kernel")
40
40
 
41
41
  BASE_COMMIT_RE = re.compile(r"(?m)^base-commit:\s*([0-9a-f]{40})\s*$")
42
+ # Cover-letter subjects use patch number 0/N. They may include:
43
+ # - Additional list prefixes: [OE-core][wrynose]
44
+ # - Version tags before or after the number: [PATCH v2 0/3] or [PATCH 00/14 v2]
45
+ COVER_SUBJECT_RE = re.compile(
46
+ r"""
47
+ ^ # Start of the subject line
48
+ (?:\[[^\]]*\]\s*)* # Optional prefixes, such as [OE-core]
49
+ \[[^\]]*\b0+/\d+ # Cover marker, such as `[PATCH v2 0/3` or `[PATCH 00/14`
50
+ [^\]]*\] # Optional suffix, such as v2 or RESEND, and closing ]
51
+ """,
52
+ re.MULTILINE | re.VERBOSE,
53
+ )
42
54
  PATCHWISE_SERIES_REF_PREFIX = "refs/patchwise/series"
43
55
 
44
56
 
@@ -269,16 +281,22 @@ def get_patch_series(
269
281
  for sibling in siblings:
270
282
  if subject_is_reply(sibling.get("Subject", "")):
271
283
  continue
272
- if sibling.get("Message-Id") == in_reply_to:
284
+ # Without a cover letter, later patches reply to patch 1/N, which
285
+ # belongs in the series rather than being taken as the cover.
286
+ if sibling.get("Message-Id") == in_reply_to and COVER_SUBJECT_RE.match(
287
+ decode_header_value(sibling.get("Subject", ""))
288
+ ):
273
289
  cover = sibling
274
290
  else:
275
291
  patches.append(sibling)
276
292
 
277
293
  patches.sort(key=lambda m: utils.parsedate_to_datetime(m["Date"]))
278
294
 
295
+ # Without a cover letter, base-commit is in the first patch
279
296
  base_commit: Optional[str] = None
280
- if cover:
281
- match = BASE_COMMIT_RE.search(_decode_body(cover))
297
+ base_commit_source = cover or (patches[0] if patches else None)
298
+ if base_commit_source:
299
+ match = BASE_COMMIT_RE.search(_decode_body(base_commit_source))
282
300
  if match:
283
301
  base_commit = match.group(1)
284
302
 
@@ -400,16 +418,14 @@ def decode_single_header(contents):
400
418
 
401
419
 
402
420
  def process_mail(
421
+ mail_client: MailClient,
403
422
  criteria,
404
423
  reviews: set[str],
405
424
  config: MailConfig,
406
- send: bool = False,
407
425
  fix: bool = False,
408
426
  ):
409
- logger.info(f"IMAP: {config.imap.server}:{config.imap.port}")
410
- logger.info(f"SMTP: {config.smtp.server}:{config.smtp.port}")
411
-
412
- mail_client = MailClient(config, send=send)
427
+ # The session may have been dropped while idle between watch cycles.
428
+ mail_client.ensure_connected()
413
429
 
414
430
  search_ids = mail_client.search(criteria)
415
431