patchwise 0.9.3__tar.gz → 0.9.5__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.
- {patchwise-0.9.3 → patchwise-0.9.5}/PKG-INFO +17 -12
- {patchwise-0.9.3 → patchwise-0.9.5}/README.md +15 -10
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/default_config.yaml +2 -2
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/docker.py +79 -154
- patchwise-0.9.5/patchwise/dockerfiles/CrashdumpAgent.Dockerfile +22 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/dockerfiles/base.Dockerfile +0 -13
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/mail_handler/cli.py +6 -1
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/mail_handler/handler.py +24 -8
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/mail_handler/mail_client.py +59 -15
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/main.py +11 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/__init__.py +5 -2
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/ai_agent/agent.py +110 -51
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/ai_agent/tool_definitions.py +68 -25
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/ai_review/ai_code_review.py +179 -297
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/ai_review/llm_commit_audit.py +1 -1
- patchwise-0.9.5/patchwise/patch_review/ai_review/review_prompts.py +60 -0
- patchwise-0.9.5/patchwise/patch_review/ai_review/root_cause_analysis.py +889 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/patch_review.py +6 -5
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/ui/dashboard.py +8 -2
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/ui/events.py +1 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise.egg-info/PKG-INFO +17 -12
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise.egg-info/SOURCES.txt +1 -1
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise.egg-info/requires.txt +1 -1
- {patchwise-0.9.3 → patchwise-0.9.5}/pyproject.toml +2 -2
- {patchwise-0.9.3 → patchwise-0.9.5}/tests/test_mail_handler_series_refs.py +97 -0
- patchwise-0.9.3/patchwise/dockerfiles/CrashdumpAgent.Dockerfile +0 -12
- patchwise-0.9.3/patchwise/patch_review/ai_agent/crashdump_agent.py +0 -368
- patchwise-0.9.3/patchwise/patch_review/ai_review/root_cause_analysis.py +0 -1314
- {patchwise-0.9.3 → patchwise-0.9.5}/LICENSE.txt +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/__init__.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/dockerfiles/AiCodeReview.Dockerfile +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/dockerfiles/Checkpatch.Dockerfile +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/dockerfiles/Coccicheck.Dockerfile +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/dockerfiles/DtCheck.Dockerfile +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/dockerfiles/DtbsCheck.Dockerfile +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/dockerfiles/LLMCommitAudit.Dockerfile +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/dockerfiles/Sparse.Dockerfile +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/logger_setup.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/mail_handler/__init__.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/mail_handler/ai_models.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/mail_handler/config.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/mail_handler/utils.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/ai_agent/__init__.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/ai_fix/__init__.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/ai_fix/ai_fix.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/ai_fix/ai_patch_fix.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/ai_fix/checkpatch_fixer.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/ai_fix/kernel_docs_rag.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/ai_fix/sparse_fixer.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/ai_review/__init__.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/ai_review/ai_review.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/ai_review/fetch_reviewer_comment.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/ai_review/ts_cache.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/ai_review/ts_indexer.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/decorators.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/kernel_tree.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/static_analysis/__init__.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/static_analysis/checkpatch.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/static_analysis/coccicheck.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/static_analysis/dt_check.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/static_analysis/dtbs_check.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/static_analysis/sparse.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/patch_review/static_analysis/static_analysis.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/stats/__init__.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/stats/dashboard.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/ui/__init__.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/ui/screen.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/utils/config.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/utils/decorators.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/utils/lru_cache.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/utils/repo_workspace.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise/utils/tui.py +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise.egg-info/dependency_links.txt +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise.egg-info/entry_points.txt +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/patchwise.egg-info/top_level.txt +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/setup.cfg +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/false-positive-guide.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/alignment.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/arm64.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/ata.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/block.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/bluetooth.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/boot-params.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/bpf.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/btf.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/btrfs.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/build.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/cleanup.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/cxl.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/dax.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/drm.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/dt-bindings.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/fscrypt.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/gic-v3.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/gic-v5.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/hid.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/hyp-arm64.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/i2c.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/input.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/io-accessors.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/io_uring.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/kconfig.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/kho.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/kvm-arm64.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/kvm.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/libbpf.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/locking.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/mips.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/mm-alloc.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/mm-folio.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/mm-largepage.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/mm-pagetable.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/mm-reclaim.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/mm-vma.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/netlink.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/networking-core.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/networking-drivers.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/nfsd.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/objtool.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/of.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/pci.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/perf.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/pm.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/pmdomain.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/rcu.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/rust.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/scheduler.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/selftests.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/smb-ksmbd.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/subjective-review.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/subsystem-template.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/subsystem.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/sunrpc.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/syscall.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/sysfs.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/timers.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/tracing.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/tty.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/usb-storage.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/vfs.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/wireless.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/thirdparty/review-prompts/kernel/subsystem/workqueue.md +0 -0
- {patchwise-0.9.3 → patchwise-0.9.5}/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
|
+
Version: 0.9.5
|
|
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
|
|
13
|
+
Requires-Dist: litellm<=1.105.4,>=1.103.0
|
|
14
14
|
Requires-Dist: cachetools>=5.5.2
|
|
15
15
|
Requires-Dist: chromadb>=0.4.0
|
|
16
16
|
Requires-Dist: yamllint>=1.26.3
|
|
@@ -167,8 +167,8 @@ Dynamic: license-file
|
|
|
167
167
|
### AI Code Review
|
|
168
168
|
|
|
169
169
|
`AiCodeReview` reviews a patch in three phases: **PLAN** (a planner ↔ critic
|
|
170
|
-
loop splits the diff into analysis angles), **EXEC** (a
|
|
171
|
-
|
|
170
|
+
loop splits the diff into analysis angles), **EXEC** (a single reviewer covers
|
|
171
|
+
all the angles in one pass against the real code), and **FILTER** (drops
|
|
172
172
|
proven false positives) before rendering the final inline review.
|
|
173
173
|
|
|
174
174
|
```bash
|
|
@@ -186,7 +186,7 @@ flowchart TD
|
|
|
186
186
|
end
|
|
187
187
|
|
|
188
188
|
B(( )) --> P
|
|
189
|
-
C -->|converged| D["EXEC\n(
|
|
189
|
+
C -->|converged| D["EXEC\n(review)"]
|
|
190
190
|
D --> E["FILTER\n(drop false positives)"]
|
|
191
191
|
E --> F(["Inline review"])
|
|
192
192
|
```
|
|
@@ -195,7 +195,7 @@ Each phase has its own iteration budget, each overridable via env:
|
|
|
195
195
|
|
|
196
196
|
| Phase | Default cap | Override env |
|
|
197
197
|
|-------|-------------|---------------|
|
|
198
|
-
| Critic loop | `MAX_PLAN_ITERATIONS =
|
|
198
|
+
| Critic loop | `MAX_PLAN_ITERATIONS = 5` rounds | `PATCHWISE_MAX_PLAN_ITERATIONS` |
|
|
199
199
|
| Critic (per round) | `CRITIC_ITER_CAP = 10` | `PATCHWISE_CRITIC_ITER_CAP` |
|
|
200
200
|
| Execution | `EXEC_ITER_CAP = 100` | `PATCHWISE_EXEC_ITER_CAP` |
|
|
201
201
|
| FP filter | `FP_ITER_CAP = 50` | `PATCHWISE_FP_ITER_CAP` |
|
|
@@ -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> --
|
|
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> --
|
|
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(["
|
|
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:
|
|
@@ -373,7 +377,7 @@ PatchWise merges [`patchwise/default_config.yaml`](patchwise/default_config.yaml
|
|
|
373
377
|
|
|
374
378
|
### Ai Review Options
|
|
375
379
|
|
|
376
|
-
- `--model`: Specify the AI model to use for code review. (default: `openai/Pro`).
|
|
380
|
+
- `--model`: Specify the AI model to use for code review. (default: `openai/responses/Pro`). Use the `openai/responses/` prefix for OpenAI models, e.g. `openai/responses/gpt-6.1-sol`, which routes requests through the `/v1/responses`.
|
|
377
381
|
- `--provider`: The base URL for the AI model API. (default: `https://api.openai.com/v1`)
|
|
378
382
|
- `--reasoning-effort`: Reasoning-effort hint for reasoning models, e.g. `low`/`medium`/`high`. Unset uses the model default.
|
|
379
383
|
- `--additional-context`: Extra text injected into the review/analysis prompt (e.g. a known reproducer or debugging notes). Shared across review and `--rca` modes.
|
|
@@ -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`:
|
|
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
|
|
|
@@ -130,8 +130,8 @@
|
|
|
130
130
|
### AI Code Review
|
|
131
131
|
|
|
132
132
|
`AiCodeReview` reviews a patch in three phases: **PLAN** (a planner ↔ critic
|
|
133
|
-
loop splits the diff into analysis angles), **EXEC** (a
|
|
134
|
-
|
|
133
|
+
loop splits the diff into analysis angles), **EXEC** (a single reviewer covers
|
|
134
|
+
all the angles in one pass against the real code), and **FILTER** (drops
|
|
135
135
|
proven false positives) before rendering the final inline review.
|
|
136
136
|
|
|
137
137
|
```bash
|
|
@@ -149,7 +149,7 @@ flowchart TD
|
|
|
149
149
|
end
|
|
150
150
|
|
|
151
151
|
B(( )) --> P
|
|
152
|
-
C -->|converged| D["EXEC\n(
|
|
152
|
+
C -->|converged| D["EXEC\n(review)"]
|
|
153
153
|
D --> E["FILTER\n(drop false positives)"]
|
|
154
154
|
E --> F(["Inline review"])
|
|
155
155
|
```
|
|
@@ -158,7 +158,7 @@ Each phase has its own iteration budget, each overridable via env:
|
|
|
158
158
|
|
|
159
159
|
| Phase | Default cap | Override env |
|
|
160
160
|
|-------|-------------|---------------|
|
|
161
|
-
| Critic loop | `MAX_PLAN_ITERATIONS =
|
|
161
|
+
| Critic loop | `MAX_PLAN_ITERATIONS = 5` rounds | `PATCHWISE_MAX_PLAN_ITERATIONS` |
|
|
162
162
|
| Critic (per round) | `CRITIC_ITER_CAP = 10` | `PATCHWISE_CRITIC_ITER_CAP` |
|
|
163
163
|
| Execution | `EXEC_ITER_CAP = 100` | `PATCHWISE_EXEC_ITER_CAP` |
|
|
164
164
|
| FP filter | `FP_ITER_CAP = 50` | `PATCHWISE_FP_ITER_CAP` |
|
|
@@ -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> --
|
|
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> --
|
|
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(["
|
|
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:
|
|
@@ -336,7 +340,7 @@ PatchWise merges [`patchwise/default_config.yaml`](patchwise/default_config.yaml
|
|
|
336
340
|
|
|
337
341
|
### Ai Review Options
|
|
338
342
|
|
|
339
|
-
- `--model`: Specify the AI model to use for code review. (default: `openai/Pro`).
|
|
343
|
+
- `--model`: Specify the AI model to use for code review. (default: `openai/responses/Pro`). Use the `openai/responses/` prefix for OpenAI models, e.g. `openai/responses/gpt-6.1-sol`, which routes requests through the `/v1/responses`.
|
|
340
344
|
- `--provider`: The base URL for the AI model API. (default: `https://api.openai.com/v1`)
|
|
341
345
|
- `--reasoning-effort`: Reasoning-effort hint for reasoning models, e.g. `low`/`medium`/`high`. Unset uses the model default.
|
|
342
346
|
- `--additional-context`: Extra text injected into the review/analysis prompt (e.g. a known reproducer or debugging notes). Shared across review and `--rca` modes.
|
|
@@ -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`:
|
|
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
|
|
|
@@ -17,7 +17,7 @@ git_committer:
|
|
|
17
17
|
name: "Patchwise"
|
|
18
18
|
email: "patchwise@qualcomm.com"
|
|
19
19
|
ai:
|
|
20
|
-
model: "openai/Pro"
|
|
20
|
+
model: "openai/responses/Pro"
|
|
21
21
|
provider: "https://api.openai.com/v1"
|
|
22
22
|
# API key for the AI model API. Leave empty to fall back to the provider's
|
|
23
23
|
# usual environment variable (e.g. OPENAI_API_KEY). Override in
|
|
@@ -28,7 +28,7 @@ ai:
|
|
|
28
28
|
# ~/.config/patchwise_config.yaml, e.g.:
|
|
29
29
|
# ai:
|
|
30
30
|
# models:
|
|
31
|
-
# openai/Pro: "
|
|
31
|
+
# openai/responses/Pro: "The Pro model"
|
|
32
32
|
models: {}
|
|
33
33
|
# Accepts: "inline" or "gerrit".
|
|
34
34
|
output_format: "inline"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
|
|
2
2
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
3
3
|
|
|
4
|
+
import os
|
|
4
5
|
import logging
|
|
5
6
|
import subprocess
|
|
6
7
|
import sys
|
|
@@ -43,6 +44,9 @@ class DockerManager:
|
|
|
43
44
|
# Class-level tracking for initialization
|
|
44
45
|
build_volume_initialized = False
|
|
45
46
|
_build_volume_name = "patchwise-shared-build"
|
|
47
|
+
sandbox_path = Path("/home") / PACKAGE_NAME
|
|
48
|
+
build_dir = sandbox_path / "build"
|
|
49
|
+
kernel_dir = sandbox_path / "kernel"
|
|
46
50
|
|
|
47
51
|
# Nothing we run in a container needs network (packages are installed at image
|
|
48
52
|
# build time), and the agent runs model-composed shell commands over an
|
|
@@ -76,9 +80,6 @@ class DockerManager:
|
|
|
76
80
|
# kernel_platform --project common`). Empty => the mount root is the git
|
|
77
81
|
# tree (the common case), so existing callers are unchanged.
|
|
78
82
|
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
83
|
self._kernel_overlay_volume: Optional[str] = None
|
|
83
84
|
require_workspace_root(str(self.repo_path))
|
|
84
85
|
self._repo_managed = is_repo_managed(str(self.repo_path))
|
|
@@ -122,7 +123,7 @@ class DockerManager:
|
|
|
122
123
|
subprocess.run(["docker", "volume", "rm", "-f", vol], capture_output=True)
|
|
123
124
|
|
|
124
125
|
# Create the backing volume that will hold upper/ and work/.
|
|
125
|
-
self.logger.
|
|
126
|
+
self.logger.debug(
|
|
126
127
|
f"Creating kernel overlay backing volume '{backing_volume}' "
|
|
127
128
|
f"for {self.container_name}..."
|
|
128
129
|
)
|
|
@@ -172,7 +173,7 @@ class DockerManager:
|
|
|
172
173
|
upper = f"{backing_mountpoint}/upper"
|
|
173
174
|
work = f"{backing_mountpoint}/work"
|
|
174
175
|
|
|
175
|
-
self.logger.
|
|
176
|
+
self.logger.debug(
|
|
176
177
|
f"Creating kernel overlay volume '{volume_name}' for {self.container_name}..."
|
|
177
178
|
)
|
|
178
179
|
subprocess.run(
|
|
@@ -193,7 +194,7 @@ class DockerManager:
|
|
|
193
194
|
check=True,
|
|
194
195
|
capture_output=True,
|
|
195
196
|
)
|
|
196
|
-
self.logger.
|
|
197
|
+
self.logger.debug(f"Kernel overlay volume '{volume_name}' created.")
|
|
197
198
|
return volume_name
|
|
198
199
|
|
|
199
200
|
def _cleanup_kernel_overlay(self) -> None:
|
|
@@ -262,8 +263,13 @@ class DockerManager:
|
|
|
262
263
|
f"Tool-specific image {self.image_tag} built successfully."
|
|
263
264
|
)
|
|
264
265
|
|
|
265
|
-
def
|
|
266
|
-
|
|
266
|
+
def _start_container(
|
|
267
|
+
self,
|
|
268
|
+
mounts: list[str],
|
|
269
|
+
*,
|
|
270
|
+
reset_tree: bool = True,
|
|
271
|
+
) -> None:
|
|
272
|
+
"""Start a container and run the common post-start preparation."""
|
|
267
273
|
try:
|
|
268
274
|
self._kernel_overlay_volume = self._setup_kernel_overlay()
|
|
269
275
|
except subprocess.CalledProcessError as e:
|
|
@@ -279,6 +285,10 @@ class DockerManager:
|
|
|
279
285
|
["docker", "rm", "-f", self.container_name],
|
|
280
286
|
capture_output=True,
|
|
281
287
|
)
|
|
288
|
+
overlay = self._kernel_overlay_volume
|
|
289
|
+
if overlay is None:
|
|
290
|
+
raise RuntimeError("kernel overlay volume was not created")
|
|
291
|
+
mounts = [*mounts, f"{overlay}:{self.kernel_dir}"]
|
|
282
292
|
args = [
|
|
283
293
|
"docker",
|
|
284
294
|
"run",
|
|
@@ -286,18 +296,11 @@ class DockerManager:
|
|
|
286
296
|
"--name",
|
|
287
297
|
self.container_name,
|
|
288
298
|
*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
299
|
]
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
300
|
+
for mount in mounts:
|
|
301
|
+
args += ["-v", mount]
|
|
302
|
+
args += [self.image_tag, "tail", "-f", "/dev/null"]
|
|
303
|
+
self.logger.info(f"Starting container {self.container_name}...")
|
|
301
304
|
try:
|
|
302
305
|
subprocess.run(
|
|
303
306
|
args,
|
|
@@ -322,7 +325,7 @@ class DockerManager:
|
|
|
322
325
|
raise
|
|
323
326
|
|
|
324
327
|
try:
|
|
325
|
-
self._prepare_kernel_tree()
|
|
328
|
+
self._prepare_kernel_tree(reset_tree=reset_tree)
|
|
326
329
|
except subprocess.CalledProcessError as e:
|
|
327
330
|
self.logger.error(
|
|
328
331
|
f"Failed to prepare kernel tree at {self.commit_sha}: {e}\nstderr: {e.stderr}"
|
|
@@ -330,6 +333,37 @@ class DockerManager:
|
|
|
330
333
|
self._cleanup_kernel_overlay()
|
|
331
334
|
raise
|
|
332
335
|
|
|
336
|
+
def start_container(
|
|
337
|
+
self,
|
|
338
|
+
mounts: dict[Path, str] = {},
|
|
339
|
+
*,
|
|
340
|
+
mount_shared_build: bool = True,
|
|
341
|
+
reset_tree: bool = True,
|
|
342
|
+
) -> None:
|
|
343
|
+
"""Start a container with caller-selected mounts.
|
|
344
|
+
|
|
345
|
+
Mount destinations may include Docker options, such as ``:ro``.
|
|
346
|
+
"""
|
|
347
|
+
docker_mounts = []
|
|
348
|
+
if mount_shared_build:
|
|
349
|
+
docker_mounts.append(f"{self._build_volume_name}:{self.build_dir}")
|
|
350
|
+
docker_mounts.extend(f"{host}:{dest}" for host, dest in mounts.items())
|
|
351
|
+
|
|
352
|
+
# Don't reset repo-managed trees; simply assume review-ready
|
|
353
|
+
if self._repo_managed:
|
|
354
|
+
reset_tree = False
|
|
355
|
+
self._start_container(docker_mounts, reset_tree=reset_tree)
|
|
356
|
+
|
|
357
|
+
if mount_shared_build:
|
|
358
|
+
try:
|
|
359
|
+
self._fix_build_directory_permissions()
|
|
360
|
+
except subprocess.CalledProcessError as e:
|
|
361
|
+
self.logger.error(
|
|
362
|
+
f"Failed to fix build directory permissions: {e}\nstderr: {e.stderr}"
|
|
363
|
+
)
|
|
364
|
+
self._cleanup_kernel_overlay()
|
|
365
|
+
raise
|
|
366
|
+
|
|
333
367
|
def run_command(
|
|
334
368
|
self, command: list[str], cwd: Optional[str], **kwargs: Any
|
|
335
369
|
) -> subprocess.Popen[str]:
|
|
@@ -505,13 +539,13 @@ class DockerManager:
|
|
|
505
539
|
return
|
|
506
540
|
except subprocess.CalledProcessError:
|
|
507
541
|
# Volume doesn't exist, create it
|
|
508
|
-
logger.
|
|
542
|
+
logger.debug(f"Creating shared build volume {cls._build_volume_name}...")
|
|
509
543
|
subprocess.run(
|
|
510
544
|
["docker", "volume", "create", cls._build_volume_name],
|
|
511
545
|
check=True,
|
|
512
546
|
capture_output=True,
|
|
513
547
|
)
|
|
514
|
-
logger.
|
|
548
|
+
logger.debug(f"Volume {cls._build_volume_name} created successfully.")
|
|
515
549
|
|
|
516
550
|
@classmethod
|
|
517
551
|
def initialize_shared_build_volume(
|
|
@@ -524,14 +558,14 @@ class DockerManager:
|
|
|
524
558
|
logger.debug("Build volume already initialized, skipping.")
|
|
525
559
|
return
|
|
526
560
|
|
|
527
|
-
logger.
|
|
561
|
+
logger.debug("Initializing shared build volume...")
|
|
528
562
|
|
|
529
563
|
# Ensure the volume exists
|
|
530
564
|
cls.create_shared_build_volume()
|
|
531
565
|
|
|
532
566
|
# Create a temporary base container to initialize the volume
|
|
533
567
|
base_image_tag = "patchwise-base:latest"
|
|
534
|
-
init_container_name = f"patchwise-init-{current_commit_sha[:8]}"
|
|
568
|
+
init_container_name = f"patchwise-init-{current_commit_sha[:8]}-{os.getpid()}"
|
|
535
569
|
|
|
536
570
|
try:
|
|
537
571
|
# Start container with the shared volume mounted
|
|
@@ -544,7 +578,7 @@ class DockerManager:
|
|
|
544
578
|
init_container_name,
|
|
545
579
|
*cls._NETWORK_ARGS,
|
|
546
580
|
"-v",
|
|
547
|
-
f"{cls._build_volume_name}
|
|
581
|
+
f"{cls._build_volume_name}:{cls.build_dir}",
|
|
548
582
|
base_image_tag,
|
|
549
583
|
"tail",
|
|
550
584
|
"-f",
|
|
@@ -568,9 +602,9 @@ class DockerManager:
|
|
|
568
602
|
(
|
|
569
603
|
"set -e; "
|
|
570
604
|
"echo 'Initializing shared build directory...'; "
|
|
571
|
-
"mkdir -p
|
|
572
|
-
"chown -R patchwise:patchwise
|
|
573
|
-
"chmod -R 755
|
|
605
|
+
f"mkdir -p {cls.build_dir}; "
|
|
606
|
+
f"chown -R patchwise:patchwise {cls.build_dir}; "
|
|
607
|
+
f"chmod -R 755 {cls.build_dir}; "
|
|
574
608
|
"echo 'Build directory initialized successfully'"
|
|
575
609
|
),
|
|
576
610
|
],
|
|
@@ -578,7 +612,7 @@ class DockerManager:
|
|
|
578
612
|
capture_output=True,
|
|
579
613
|
)
|
|
580
614
|
|
|
581
|
-
logger.
|
|
615
|
+
logger.debug("Shared build volume initialized successfully.")
|
|
582
616
|
cls.build_volume_initialized = True
|
|
583
617
|
|
|
584
618
|
finally:
|
|
@@ -635,7 +669,7 @@ class DockerManager:
|
|
|
635
669
|
cls.ts_cache_initialized = True
|
|
636
670
|
return
|
|
637
671
|
# Exists but stopped — restart it rather than recreate (name is taken).
|
|
638
|
-
logger.
|
|
672
|
+
logger.debug(
|
|
639
673
|
f"Restarting stopped ts-cache container {cls._ts_cache_container}..."
|
|
640
674
|
)
|
|
641
675
|
subprocess.run(
|
|
@@ -647,7 +681,7 @@ class DockerManager:
|
|
|
647
681
|
cls.ts_cache_initialized = True
|
|
648
682
|
return
|
|
649
683
|
|
|
650
|
-
logger.
|
|
684
|
+
logger.debug(f"Starting ts-cache container {cls._ts_cache_container}...")
|
|
651
685
|
host, port = redis_address()
|
|
652
686
|
subprocess.run(
|
|
653
687
|
[
|
|
@@ -675,7 +709,7 @@ class DockerManager:
|
|
|
675
709
|
capture_output=True,
|
|
676
710
|
)
|
|
677
711
|
cls._wait_ts_cache_ready()
|
|
678
|
-
logger.
|
|
712
|
+
logger.debug(f"ts-cache container {cls._ts_cache_container} started.")
|
|
679
713
|
cls.ts_cache_initialized = True
|
|
680
714
|
|
|
681
715
|
@classmethod
|
|
@@ -698,140 +732,34 @@ class DockerManager:
|
|
|
698
732
|
)
|
|
699
733
|
time.sleep(1)
|
|
700
734
|
|
|
701
|
-
def
|
|
702
|
-
"""
|
|
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.)"""
|
|
735
|
+
def _prepare_kernel_tree(self, *, reset_tree: bool = True) -> None:
|
|
736
|
+
"""Configure Git trust and optionally reset the tree under review."""
|
|
790
737
|
self.logger.debug(
|
|
791
738
|
f"Preparing kernel tree at {self.commit_sha} in {self.container_name}..."
|
|
792
739
|
)
|
|
740
|
+
|
|
741
|
+
# Trust all repositories for Git commands in the container
|
|
793
742
|
subprocess.run(
|
|
794
743
|
[
|
|
795
744
|
"docker",
|
|
796
745
|
"exec",
|
|
797
746
|
"--user",
|
|
798
747
|
"root",
|
|
799
|
-
"--workdir",
|
|
800
|
-
self._git_workdir,
|
|
801
748
|
self.container_name,
|
|
802
749
|
"git",
|
|
803
750
|
"config",
|
|
804
|
-
"--
|
|
751
|
+
"--system",
|
|
805
752
|
"--add",
|
|
806
753
|
"safe.directory",
|
|
807
|
-
|
|
754
|
+
"*",
|
|
808
755
|
],
|
|
809
756
|
check=True,
|
|
810
757
|
capture_output=True,
|
|
811
758
|
)
|
|
812
759
|
|
|
813
|
-
|
|
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
|
-
)
|
|
760
|
+
if not reset_tree:
|
|
833
761
|
self.logger.debug(
|
|
834
|
-
"
|
|
762
|
+
"leaving the kernel tree as mounted without resetting it."
|
|
835
763
|
)
|
|
836
764
|
return
|
|
837
765
|
|
|
@@ -868,11 +796,8 @@ class DockerManager:
|
|
|
868
796
|
check=True,
|
|
869
797
|
capture_output=True,
|
|
870
798
|
)
|
|
871
|
-
# Give the agent ownership of the git tree (where git wrote during reset)
|
|
872
|
-
#
|
|
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.
|
|
799
|
+
# Give the agent ownership of the git tree (where git wrote during reset)
|
|
800
|
+
# TODO: Does resetting outside the container in --mail mode avoid this?
|
|
876
801
|
subprocess.run(
|
|
877
802
|
[
|
|
878
803
|
"docker",
|
|
@@ -933,7 +858,7 @@ class DockerManager:
|
|
|
933
858
|
self.container_name,
|
|
934
859
|
"mkdir",
|
|
935
860
|
"-p",
|
|
936
|
-
|
|
861
|
+
str(self.build_dir / self.commit_sha),
|
|
937
862
|
],
|
|
938
863
|
check=True,
|
|
939
864
|
capture_output=True,
|
|
@@ -949,7 +874,7 @@ class DockerManager:
|
|
|
949
874
|
"chown",
|
|
950
875
|
"-R",
|
|
951
876
|
"patchwise:patchwise",
|
|
952
|
-
|
|
877
|
+
str(self.build_dir / self.commit_sha),
|
|
953
878
|
],
|
|
954
879
|
check=True,
|
|
955
880
|
capture_output=True,
|
|
@@ -965,7 +890,7 @@ class DockerManager:
|
|
|
965
890
|
"chmod",
|
|
966
891
|
"-R",
|
|
967
892
|
"755",
|
|
968
|
-
|
|
893
|
+
str(self.build_dir / self.commit_sha),
|
|
969
894
|
],
|
|
970
895
|
check=True,
|
|
971
896
|
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
|