radarhound 0.1.0__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 (139) hide show
  1. radarhound-0.1.0/LICENSE +21 -0
  2. radarhound-0.1.0/PKG-INFO +239 -0
  3. radarhound-0.1.0/README.md +216 -0
  4. radarhound-0.1.0/pyproject.toml +40 -0
  5. radarhound-0.1.0/radarhound/__init__.py +3 -0
  6. radarhound-0.1.0/radarhound/backlog.py +129 -0
  7. radarhound-0.1.0/radarhound/botimport.py +222 -0
  8. radarhound-0.1.0/radarhound/budget.py +208 -0
  9. radarhound-0.1.0/radarhound/calllog.py +70 -0
  10. radarhound-0.1.0/radarhound/canary.py +576 -0
  11. radarhound-0.1.0/radarhound/chunking.py +167 -0
  12. radarhound-0.1.0/radarhound/cli.py +735 -0
  13. radarhound-0.1.0/radarhound/config.py +1117 -0
  14. radarhound-0.1.0/radarhound/discover.py +649 -0
  15. radarhound-0.1.0/radarhound/distill.py +520 -0
  16. radarhound-0.1.0/radarhound/doctype.py +705 -0
  17. radarhound-0.1.0/radarhound/engines/__init__.py +110 -0
  18. radarhound-0.1.0/radarhound/engines/fake.py +94 -0
  19. radarhound-0.1.0/radarhound/engines/template.py +637 -0
  20. radarhound-0.1.0/radarhound/eval.py +943 -0
  21. radarhound-0.1.0/radarhound/feedback.py +290 -0
  22. radarhound-0.1.0/radarhound/findings.py +440 -0
  23. radarhound-0.1.0/radarhound/follow.py +181 -0
  24. radarhound-0.1.0/radarhound/gitlab.py +768 -0
  25. radarhound-0.1.0/radarhound/gitutil.py +59 -0
  26. radarhound-0.1.0/radarhound/lessons.py +428 -0
  27. radarhound-0.1.0/radarhound/mrcontext.py +33 -0
  28. radarhound-0.1.0/radarhound/output.py +1296 -0
  29. radarhound-0.1.0/radarhound/page.py +380 -0
  30. radarhound-0.1.0/radarhound/passes/__init__.py +1 -0
  31. radarhound-0.1.0/radarhound/passes/group.py +342 -0
  32. radarhound-0.1.0/radarhound/passes/hunt.py +1349 -0
  33. radarhound-0.1.0/radarhound/passes/questions.py +2595 -0
  34. radarhound-0.1.0/radarhound/passes/verify.py +605 -0
  35. radarhound-0.1.0/radarhound/project.py +652 -0
  36. radarhound-0.1.0/radarhound/related.py +1284 -0
  37. radarhound-0.1.0/radarhound/resources/ask_prefix.md +11 -0
  38. radarhound-0.1.0/radarhound/resources/decline.txt +1 -0
  39. radarhound-0.1.0/radarhound/resources/group_prefix.md +9 -0
  40. radarhound-0.1.0/radarhound/resources/hunt_code_lenses.md +13 -0
  41. radarhound-0.1.0/radarhound/resources/hunt_doc_lenses.md +10 -0
  42. radarhound-0.1.0/radarhound/resources/hunt_prefix.md +18 -0
  43. radarhound-0.1.0/radarhound/resources/opencode-readonly.json +13 -0
  44. radarhound-0.1.0/radarhound/resources/probe_group_prefix.md +15 -0
  45. radarhound-0.1.0/radarhound/resources/probe_prefix.md +10 -0
  46. radarhound-0.1.0/radarhound/resources/profile_prefix.md +12 -0
  47. radarhound-0.1.0/radarhound/resources/related_stop.txt +173 -0
  48. radarhound-0.1.0/radarhound/resources/router_b.md +8 -0
  49. radarhound-0.1.0/radarhound/resources/sibling_prefix.md +1 -0
  50. radarhound-0.1.0/radarhound/review.py +2700 -0
  51. radarhound-0.1.0/radarhound/router.py +496 -0
  52. radarhound-0.1.0/radarhound/rules.py +678 -0
  53. radarhound-0.1.0/radarhound/scope.py +241 -0
  54. radarhound-0.1.0/radarhound/slash.py +289 -0
  55. radarhound-0.1.0/radarhound/snapshot.py +135 -0
  56. radarhound-0.1.0/radarhound/stats.py +320 -0
  57. radarhound-0.1.0/radarhound/structure.py +803 -0
  58. radarhound-0.1.0/radarhound.egg-info/PKG-INFO +239 -0
  59. radarhound-0.1.0/radarhound.egg-info/SOURCES.txt +137 -0
  60. radarhound-0.1.0/radarhound.egg-info/dependency_links.txt +1 -0
  61. radarhound-0.1.0/radarhound.egg-info/entry_points.txt +3 -0
  62. radarhound-0.1.0/radarhound.egg-info/top_level.txt +1 -0
  63. radarhound-0.1.0/setup.cfg +4 -0
  64. radarhound-0.1.0/tests/test_ask_caps_triage.py +1216 -0
  65. radarhound-0.1.0/tests/test_ask_close_teardown.py +48 -0
  66. radarhound-0.1.0/tests/test_ask_fail_open.py +50 -0
  67. radarhound-0.1.0/tests/test_ask_missed_shapes.py +82 -0
  68. radarhound-0.1.0/tests/test_ask_unresolved_symbol.py +42 -0
  69. radarhound-0.1.0/tests/test_backlog_tracked.py +259 -0
  70. radarhound-0.1.0/tests/test_budget_scaling.py +412 -0
  71. radarhound-0.1.0/tests/test_calllog.py +94 -0
  72. radarhound-0.1.0/tests/test_canary.py +227 -0
  73. radarhound-0.1.0/tests/test_chunking.py +89 -0
  74. radarhound-0.1.0/tests/test_classifier_timeout.py +350 -0
  75. radarhound-0.1.0/tests/test_config.py +102 -0
  76. radarhound-0.1.0/tests/test_config_classifier.py +121 -0
  77. radarhound-0.1.0/tests/test_config_cli_slash.py +289 -0
  78. radarhound-0.1.0/tests/test_config_engines.py +124 -0
  79. radarhound-0.1.0/tests/test_config_lessons.py +116 -0
  80. radarhound-0.1.0/tests/test_declared_pins.py +31 -0
  81. radarhound-0.1.0/tests/test_distill.py +255 -0
  82. radarhound-0.1.0/tests/test_doc_detection.py +671 -0
  83. radarhound-0.1.0/tests/test_eval.py +323 -0
  84. radarhound-0.1.0/tests/test_fail_streak.py +171 -0
  85. radarhound-0.1.0/tests/test_feedback.py +194 -0
  86. radarhound-0.1.0/tests/test_fetch_scope_timing.py +541 -0
  87. radarhound-0.1.0/tests/test_findings.py +122 -0
  88. radarhound-0.1.0/tests/test_findings_lessons.py +61 -0
  89. radarhound-0.1.0/tests/test_follow.py +277 -0
  90. radarhound-0.1.0/tests/test_gitlab.py +318 -0
  91. radarhound-0.1.0/tests/test_glob.py +32 -0
  92. radarhound-0.1.0/tests/test_group_findings.py +484 -0
  93. radarhound-0.1.0/tests/test_grouped_probes.py +593 -0
  94. radarhound-0.1.0/tests/test_high_risk_depth.py +94 -0
  95. radarhound-0.1.0/tests/test_history_docs.py +427 -0
  96. radarhound-0.1.0/tests/test_hunt.py +155 -0
  97. radarhound-0.1.0/tests/test_hunt_questions.py +876 -0
  98. radarhound-0.1.0/tests/test_import.py +134 -0
  99. radarhound-0.1.0/tests/test_init.py +117 -0
  100. radarhound-0.1.0/tests/test_init_backlog.py +105 -0
  101. radarhound-0.1.0/tests/test_init_discovery.py +1881 -0
  102. radarhound-0.1.0/tests/test_lessons.py +233 -0
  103. radarhound-0.1.0/tests/test_memory_dir.py +149 -0
  104. radarhound-0.1.0/tests/test_mr_context.py +507 -0
  105. radarhound-0.1.0/tests/test_mr_post.py +199 -0
  106. radarhound-0.1.0/tests/test_muse_engine.py +133 -0
  107. radarhound-0.1.0/tests/test_output.py +196 -0
  108. radarhound-0.1.0/tests/test_page.py +296 -0
  109. radarhound-0.1.0/tests/test_page_tokens.py +147 -0
  110. radarhound-0.1.0/tests/test_parallel_task_files.py +160 -0
  111. radarhound-0.1.0/tests/test_pre_existing.py +503 -0
  112. radarhound-0.1.0/tests/test_pre_existing_repeats.py +176 -0
  113. radarhound-0.1.0/tests/test_proposed_call.py +444 -0
  114. radarhound-0.1.0/tests/test_related_code.py +2025 -0
  115. radarhound-0.1.0/tests/test_release_versions.py +38 -0
  116. radarhound-0.1.0/tests/test_reliability.py +1118 -0
  117. radarhound-0.1.0/tests/test_report_modes.py +336 -0
  118. radarhound-0.1.0/tests/test_retrieval.py +244 -0
  119. radarhound-0.1.0/tests/test_review_cli.py +167 -0
  120. radarhound-0.1.0/tests/test_review_e2e.py +176 -0
  121. radarhound-0.1.0/tests/test_root_cause_sites.py +245 -0
  122. radarhound-0.1.0/tests/test_router.py +81 -0
  123. radarhound-0.1.0/tests/test_router_b.py +190 -0
  124. radarhound-0.1.0/tests/test_router_domains.py +370 -0
  125. radarhound-0.1.0/tests/test_rules_engine_gap.py +686 -0
  126. radarhound-0.1.0/tests/test_scope.py +110 -0
  127. radarhound-0.1.0/tests/test_sibling_search.py +620 -0
  128. radarhound-0.1.0/tests/test_sibling_step.py +1303 -0
  129. radarhound-0.1.0/tests/test_snapshot_cleanup.py +61 -0
  130. radarhound-0.1.0/tests/test_snapshot_head.py +70 -0
  131. radarhound-0.1.0/tests/test_snapshot_uncommitted.py +74 -0
  132. radarhound-0.1.0/tests/test_stats.py +195 -0
  133. radarhound-0.1.0/tests/test_structure_pins.py +218 -0
  134. radarhound-0.1.0/tests/test_structure_pins_scoped.py +137 -0
  135. radarhound-0.1.0/tests/test_structure_pins_subject.py +196 -0
  136. radarhound-0.1.0/tests/test_template.py +273 -0
  137. radarhound-0.1.0/tests/test_test_only_lock.py +483 -0
  138. radarhound-0.1.0/tests/test_token_usage.py +377 -0
  139. radarhound-0.1.0/tests/test_verify.py +129 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mohammedsaif Kordia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,239 @@
1
+ Metadata-Version: 2.4
2
+ Name: radarhound
3
+ Version: 0.1.0
4
+ Summary: Radarhound: a local code reviewer that investigates the repository and learns from feedback
5
+ Author: Mohammedsaif Kordia
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/radarhound/radarhound
8
+ Project-URL: Repository, https://github.com/radarhound/radarhound
9
+ Project-URL: Issues, https://github.com/radarhound/radarhound/issues
10
+ Project-URL: Documentation, https://github.com/radarhound/radarhound/tree/main/docs
11
+ Keywords: code-review,llm,git,gitlab
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Quality Assurance
19
+ Requires-Python: >=3.12
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Dynamic: license-file
23
+
24
+ # Radarhound
25
+
26
+ A code reviewer that runs on your machine, investigates the repository
27
+ instead of reading only the diff, and learns from your replies.
28
+
29
+ It drives a coding-agent CLI you already have (Claude Code by default) in
30
+ read-only mode against a throw-away snapshot of your commit. It has no server
31
+ and no third-party Python dependencies.
32
+
33
+ **Status: early.** It is used daily on its author's GitLab projects on Windows.
34
+ The tests pass on Windows, Linux and macOS, but real reviews have only been
35
+ run on Windows, and GitHub pull requests are not supported yet. See
36
+ [ROADMAP.md](https://github.com/radarhound/radarhound/blob/main/ROADMAP.md); help is welcome.
37
+
38
+ ## How it works
39
+
40
+ 1. **Scope.** `rh review` resolves what changed (the whole merge request, or
41
+ only what is new since the last review) and a router decides how deep to
42
+ go. Docs-only changes can be skipped; high-risk files always get a deep
43
+ review.
44
+ 2. **Hunt.** The model lists risky changed lines as checkable claims, then
45
+ probes each claim with read, grep and glob tools on a snapshot of the head
46
+ commit. Every finding must cite `file:line` evidence.
47
+ 3. **Verify.** A separate pass tries to refute each finding and drops the ones
48
+ it cannot prove. Duplicates are grouped into one finding per root cause.
49
+ 4. **Report.** `reviews/<id>.md` and `.json`, with a severity, a proposed call
50
+ (`fix now`, `lean`, `backlog`) and a fix cost on every finding.
51
+ 5. **Learn.** `rh feedback <fingerprint> accept|decline` records your call.
52
+ Feedback is distilled into short project lessons that later hunts read, and
53
+ a declined finding is not raised again.
54
+
55
+ Some checks need no model at all, for example predicting which source-text
56
+ tests a change will break.
57
+
58
+ ## Does it find things?
59
+
60
+ These are the author's own records on private projects, side by side with a
61
+ paid AI code review service that ran on the same commit ranges. The full
62
+ tables are in [docs/TRIAL.md](https://github.com/radarhound/radarhound/blob/main/docs/TRIAL.md).
63
+
64
+ | | Radarhound | Paid reviewer |
65
+ |---|---|---|
66
+ | Confirmed defects found, 8 scored rounds (69 in total) | **53 (77%)** | 33 (48%) |
67
+ | Rounds with the larger share, of those 8 | **8** | 0 |
68
+ | Critical or Major defects that only the other one found | **4 missed** | 13 missed (1 Critical, 12 Major) |
69
+ | A later scored round (12 in-scope defects) | **11** | 0 |
70
+
71
+ It is not a clean sweep. On five later merge requests the paid reviewer caught
72
+ a real defect that Radarhound missed, one of them a Major on a money path.
73
+ Scored against an answer key made only of the paid reviewer's past findings,
74
+ Radarhound raises 43% of them; the paid reviewer itself, run 4 times on one
75
+ diff with 6 known defects, found 5, 2, 1.5 and 2.
76
+
77
+ Volume so far: 182 reviews on four private repositories. On one day of human
78
+ triage, 35 of 48 findings were real (73%).
79
+
80
+ ## Requirements
81
+
82
+ - Python 3.12 or newer
83
+ - git
84
+ - One engine CLI, signed in. The default is `claude` (Claude Code), which
85
+ `rh` runs with `Read`, `Grep` and `Glob` only.
86
+ - Optional: `glab`, for GitLab merge requests
87
+
88
+ ## Install
89
+
90
+ ```text
91
+ uv tool install radarhound
92
+ ```
93
+
94
+ or `pipx install radarhound`, or `pip install radarhound` inside a virtual
95
+ environment. This gives you the `rh` command (`radarhound` is the same
96
+ command). To try it without installing, run `uvx radarhound --help`.
97
+
98
+ For the newest unreleased code, install from GitHub instead:
99
+ `uv tool install git+https://github.com/radarhound/radarhound`.
100
+
101
+ ## Quick start
102
+
103
+ In any git repository:
104
+
105
+ ```text
106
+ rh init # creates .radarhound/ with a commented config.toml
107
+ rh canary # checks each default engine: finds a symbol, cannot write, cannot run a shell
108
+ rh init --refresh # profiles the repo, now that an engine has passed its canary
109
+ rh review # reviews your branch against the target branch
110
+ ```
111
+
112
+ `rh review` refuses an engine that has no passing canary. Before the first
113
+ review, set `target_branch` in `.radarhound/config.toml` if your base branch
114
+ is not `main`. The review is written to `.radarhound/reviews/`.
115
+
116
+ [docs/WALKTHROUGH.md](https://github.com/radarhound/radarhound/blob/main/docs/WALKTHROUGH.md) follows one change through a full
117
+ cycle: review, verdicts, fix, re-review and the lesson learned from it.
118
+
119
+ Useful variations:
120
+
121
+ ```text
122
+ rh review --dry-run # print the decision and the chunks, write nothing
123
+ rh review --scope latest # only what changed since the last review
124
+ rh review --mode scout # material findings only (default: hound, everything real)
125
+ rh review --mr 123 # review GitLab merge request 123
126
+ rh follow --source origin --branch my-branch # review every new push
127
+ rh feedback <fingerprint> decline --reason "by design"
128
+ rh page # an HTML page of every option and the recent runs
129
+ rh stats # reviews, findings, time and money
130
+ ```
131
+
132
+ `rh <command> --help` lists every flag.
133
+
134
+ ## Use from Claude Code
135
+
136
+ Install the slash commands into the project, once:
137
+
138
+ ```text
139
+ rh slash install --dir .claude/commands
140
+ ```
141
+
142
+ Use the project's own `.claude/commands`. Each command file names one
143
+ repository, so a shared folder such as `~/.claude/commands` can serve only one
144
+ project.
145
+
146
+ Then, in a Claude Code session:
147
+
148
+ 1. `/rh-review` runs the review in the background, reads the report and lists
149
+ every finding with its proposed call.
150
+ 2. Tell Claude which findings to fix and which to decline, in plain words. It
151
+ records each verdict with `rh feedback <fingerprint> accept|decline|fixed`;
152
+ the report ends with a ready-made command for every finding.
153
+ 3. `/rh-review --scope latest` reviews only the fix.
154
+
155
+ The other commands are `/rh-status`, `/rh-config`, `/rh-mode`, `/rh-hunt`,
156
+ `/rh-pre`, `/rh-depth`, `/rh-scope` and `/rh-page`. `rh init` and `rh canary`
157
+ have no slash command; run them in a terminal.
158
+
159
+ ## Commands
160
+
161
+ | Command | What it does |
162
+ |---|---|
163
+ | `rh init` | Create `.radarhound/` (config, memory, findings, state, reviews) |
164
+ | `rh canary [engine...]` | Check that an engine can read and cannot write or run a shell |
165
+ | `rh review` | Review the current change scope |
166
+ | `rh follow` | Follow a branch and review every new push |
167
+ | `rh feedback` | Accept or decline a finding, or record a miss |
168
+ | `rh learn` | Distill feedback into lessons; import past review history |
169
+ | `rh lessons` | List, show, add or retire lessons |
170
+ | `rh eval <key.json>` | Score reviews against an answer key |
171
+ | `rh stats` | Report reviews, findings, time and money |
172
+ | `rh config` | Show, get or set a config value |
173
+ | `rh slash install --dir <dir>` | Install `/rh-*` slash commands for Claude Code |
174
+ | `rh page` | Write a page showing every option and the recent runs |
175
+
176
+ Exit codes: 0 reviewed, 1 incomplete or failed calls, 2 refused or git error, 3 an engine has no passing canary or another review is already running.
177
+
178
+ ## Configuration
179
+
180
+ Everything is in `.radarhound/config.toml`, written by `rh init` with a
181
+ comment on every key. The ones you will touch first:
182
+
183
+ | Key | Meaning |
184
+ |---|---|
185
+ | `target_branch` | Base branch for the merge-base |
186
+ | `hunt_engines`, `verify_engine` | Which engine runs each pass |
187
+ | `high_risk` | Globs that always get a deep review |
188
+ | `max_calls_per_review`, `max_minutes` | Budgets for one review |
189
+ | `backlog_files` | Markdown backlogs; a finding that matches a row is listed as tracked |
190
+ | `gitlab_project` | GitLab project path for `--mr` |
191
+ | `review_bot_users` | Usernames of review bots on GitLab; `rh learn --from-gitlab` learns from their findings and your replies |
192
+ | `rules_yaml_file` | A YAML file of per-path review instructions to load into every review |
193
+
194
+ ## Engines
195
+
196
+ An engine is a command template in config (`[engines.<name>]`), so a new CLI
197
+ can be added without code. Shipped templates:
198
+
199
+ | Engine | State |
200
+ |---|---|
201
+ | `claude`, `claude-opus` | Default. Read-only tools |
202
+ | `opencode`, `muse` | Experimental. Read-only tools |
203
+ | `agy`, `codex` | Experimental. Tools off |
204
+ | `gemini`, `qwen`, `kilo` | Templates only, never run |
205
+
206
+ Every engine call is logged to `.radarhound/calls.jsonl` with its duration
207
+ and, when the engine reports it, token usage and cost. The review report
208
+ totals these on a `Tokens:` line.
209
+
210
+ ## Safety
211
+
212
+ - Engines run in a detached git worktree of the head commit, removed after the
213
+ review. They never run in your working tree.
214
+ - The canary checks that an engine cannot write files or run shell commands
215
+ before `rh` will use it.
216
+ - `--post` prints the API calls it would make and posts nothing.
217
+
218
+ ## Tests
219
+
220
+ ```text
221
+ python -m unittest discover -s tests
222
+ ```
223
+
224
+ The tests use a fake engine and temporary git repositories. They need git and
225
+ no model, and take a few minutes.
226
+
227
+ ## Contributing
228
+
229
+ See [CONTRIBUTING.md](https://github.com/radarhound/radarhound/blob/main/CONTRIBUTING.md) and [ROADMAP.md](https://github.com/radarhound/radarhound/blob/main/ROADMAP.md).
230
+
231
+ ## Policies
232
+
233
+ - [Privacy](https://github.com/radarhound/radarhound/blob/main/docs/PRIVACY.md): what leaves your machine, and what is stored
234
+ - [Security](https://github.com/radarhound/radarhound/blob/main/docs/SECURITY.md): how to report a vulnerability
235
+ - [Code of conduct](https://github.com/radarhound/radarhound/blob/main/docs/CODE_OF_CONDUCT.md)
236
+
237
+ ## License
238
+
239
+ [MIT](https://github.com/radarhound/radarhound/blob/main/LICENSE)
@@ -0,0 +1,216 @@
1
+ # Radarhound
2
+
3
+ A code reviewer that runs on your machine, investigates the repository
4
+ instead of reading only the diff, and learns from your replies.
5
+
6
+ It drives a coding-agent CLI you already have (Claude Code by default) in
7
+ read-only mode against a throw-away snapshot of your commit. It has no server
8
+ and no third-party Python dependencies.
9
+
10
+ **Status: early.** It is used daily on its author's GitLab projects on Windows.
11
+ The tests pass on Windows, Linux and macOS, but real reviews have only been
12
+ run on Windows, and GitHub pull requests are not supported yet. See
13
+ [ROADMAP.md](https://github.com/radarhound/radarhound/blob/main/ROADMAP.md); help is welcome.
14
+
15
+ ## How it works
16
+
17
+ 1. **Scope.** `rh review` resolves what changed (the whole merge request, or
18
+ only what is new since the last review) and a router decides how deep to
19
+ go. Docs-only changes can be skipped; high-risk files always get a deep
20
+ review.
21
+ 2. **Hunt.** The model lists risky changed lines as checkable claims, then
22
+ probes each claim with read, grep and glob tools on a snapshot of the head
23
+ commit. Every finding must cite `file:line` evidence.
24
+ 3. **Verify.** A separate pass tries to refute each finding and drops the ones
25
+ it cannot prove. Duplicates are grouped into one finding per root cause.
26
+ 4. **Report.** `reviews/<id>.md` and `.json`, with a severity, a proposed call
27
+ (`fix now`, `lean`, `backlog`) and a fix cost on every finding.
28
+ 5. **Learn.** `rh feedback <fingerprint> accept|decline` records your call.
29
+ Feedback is distilled into short project lessons that later hunts read, and
30
+ a declined finding is not raised again.
31
+
32
+ Some checks need no model at all, for example predicting which source-text
33
+ tests a change will break.
34
+
35
+ ## Does it find things?
36
+
37
+ These are the author's own records on private projects, side by side with a
38
+ paid AI code review service that ran on the same commit ranges. The full
39
+ tables are in [docs/TRIAL.md](https://github.com/radarhound/radarhound/blob/main/docs/TRIAL.md).
40
+
41
+ | | Radarhound | Paid reviewer |
42
+ |---|---|---|
43
+ | Confirmed defects found, 8 scored rounds (69 in total) | **53 (77%)** | 33 (48%) |
44
+ | Rounds with the larger share, of those 8 | **8** | 0 |
45
+ | Critical or Major defects that only the other one found | **4 missed** | 13 missed (1 Critical, 12 Major) |
46
+ | A later scored round (12 in-scope defects) | **11** | 0 |
47
+
48
+ It is not a clean sweep. On five later merge requests the paid reviewer caught
49
+ a real defect that Radarhound missed, one of them a Major on a money path.
50
+ Scored against an answer key made only of the paid reviewer's past findings,
51
+ Radarhound raises 43% of them; the paid reviewer itself, run 4 times on one
52
+ diff with 6 known defects, found 5, 2, 1.5 and 2.
53
+
54
+ Volume so far: 182 reviews on four private repositories. On one day of human
55
+ triage, 35 of 48 findings were real (73%).
56
+
57
+ ## Requirements
58
+
59
+ - Python 3.12 or newer
60
+ - git
61
+ - One engine CLI, signed in. The default is `claude` (Claude Code), which
62
+ `rh` runs with `Read`, `Grep` and `Glob` only.
63
+ - Optional: `glab`, for GitLab merge requests
64
+
65
+ ## Install
66
+
67
+ ```text
68
+ uv tool install radarhound
69
+ ```
70
+
71
+ or `pipx install radarhound`, or `pip install radarhound` inside a virtual
72
+ environment. This gives you the `rh` command (`radarhound` is the same
73
+ command). To try it without installing, run `uvx radarhound --help`.
74
+
75
+ For the newest unreleased code, install from GitHub instead:
76
+ `uv tool install git+https://github.com/radarhound/radarhound`.
77
+
78
+ ## Quick start
79
+
80
+ In any git repository:
81
+
82
+ ```text
83
+ rh init # creates .radarhound/ with a commented config.toml
84
+ rh canary # checks each default engine: finds a symbol, cannot write, cannot run a shell
85
+ rh init --refresh # profiles the repo, now that an engine has passed its canary
86
+ rh review # reviews your branch against the target branch
87
+ ```
88
+
89
+ `rh review` refuses an engine that has no passing canary. Before the first
90
+ review, set `target_branch` in `.radarhound/config.toml` if your base branch
91
+ is not `main`. The review is written to `.radarhound/reviews/`.
92
+
93
+ [docs/WALKTHROUGH.md](https://github.com/radarhound/radarhound/blob/main/docs/WALKTHROUGH.md) follows one change through a full
94
+ cycle: review, verdicts, fix, re-review and the lesson learned from it.
95
+
96
+ Useful variations:
97
+
98
+ ```text
99
+ rh review --dry-run # print the decision and the chunks, write nothing
100
+ rh review --scope latest # only what changed since the last review
101
+ rh review --mode scout # material findings only (default: hound, everything real)
102
+ rh review --mr 123 # review GitLab merge request 123
103
+ rh follow --source origin --branch my-branch # review every new push
104
+ rh feedback <fingerprint> decline --reason "by design"
105
+ rh page # an HTML page of every option and the recent runs
106
+ rh stats # reviews, findings, time and money
107
+ ```
108
+
109
+ `rh <command> --help` lists every flag.
110
+
111
+ ## Use from Claude Code
112
+
113
+ Install the slash commands into the project, once:
114
+
115
+ ```text
116
+ rh slash install --dir .claude/commands
117
+ ```
118
+
119
+ Use the project's own `.claude/commands`. Each command file names one
120
+ repository, so a shared folder such as `~/.claude/commands` can serve only one
121
+ project.
122
+
123
+ Then, in a Claude Code session:
124
+
125
+ 1. `/rh-review` runs the review in the background, reads the report and lists
126
+ every finding with its proposed call.
127
+ 2. Tell Claude which findings to fix and which to decline, in plain words. It
128
+ records each verdict with `rh feedback <fingerprint> accept|decline|fixed`;
129
+ the report ends with a ready-made command for every finding.
130
+ 3. `/rh-review --scope latest` reviews only the fix.
131
+
132
+ The other commands are `/rh-status`, `/rh-config`, `/rh-mode`, `/rh-hunt`,
133
+ `/rh-pre`, `/rh-depth`, `/rh-scope` and `/rh-page`. `rh init` and `rh canary`
134
+ have no slash command; run them in a terminal.
135
+
136
+ ## Commands
137
+
138
+ | Command | What it does |
139
+ |---|---|
140
+ | `rh init` | Create `.radarhound/` (config, memory, findings, state, reviews) |
141
+ | `rh canary [engine...]` | Check that an engine can read and cannot write or run a shell |
142
+ | `rh review` | Review the current change scope |
143
+ | `rh follow` | Follow a branch and review every new push |
144
+ | `rh feedback` | Accept or decline a finding, or record a miss |
145
+ | `rh learn` | Distill feedback into lessons; import past review history |
146
+ | `rh lessons` | List, show, add or retire lessons |
147
+ | `rh eval <key.json>` | Score reviews against an answer key |
148
+ | `rh stats` | Report reviews, findings, time and money |
149
+ | `rh config` | Show, get or set a config value |
150
+ | `rh slash install --dir <dir>` | Install `/rh-*` slash commands for Claude Code |
151
+ | `rh page` | Write a page showing every option and the recent runs |
152
+
153
+ Exit codes: 0 reviewed, 1 incomplete or failed calls, 2 refused or git error, 3 an engine has no passing canary or another review is already running.
154
+
155
+ ## Configuration
156
+
157
+ Everything is in `.radarhound/config.toml`, written by `rh init` with a
158
+ comment on every key. The ones you will touch first:
159
+
160
+ | Key | Meaning |
161
+ |---|---|
162
+ | `target_branch` | Base branch for the merge-base |
163
+ | `hunt_engines`, `verify_engine` | Which engine runs each pass |
164
+ | `high_risk` | Globs that always get a deep review |
165
+ | `max_calls_per_review`, `max_minutes` | Budgets for one review |
166
+ | `backlog_files` | Markdown backlogs; a finding that matches a row is listed as tracked |
167
+ | `gitlab_project` | GitLab project path for `--mr` |
168
+ | `review_bot_users` | Usernames of review bots on GitLab; `rh learn --from-gitlab` learns from their findings and your replies |
169
+ | `rules_yaml_file` | A YAML file of per-path review instructions to load into every review |
170
+
171
+ ## Engines
172
+
173
+ An engine is a command template in config (`[engines.<name>]`), so a new CLI
174
+ can be added without code. Shipped templates:
175
+
176
+ | Engine | State |
177
+ |---|---|
178
+ | `claude`, `claude-opus` | Default. Read-only tools |
179
+ | `opencode`, `muse` | Experimental. Read-only tools |
180
+ | `agy`, `codex` | Experimental. Tools off |
181
+ | `gemini`, `qwen`, `kilo` | Templates only, never run |
182
+
183
+ Every engine call is logged to `.radarhound/calls.jsonl` with its duration
184
+ and, when the engine reports it, token usage and cost. The review report
185
+ totals these on a `Tokens:` line.
186
+
187
+ ## Safety
188
+
189
+ - Engines run in a detached git worktree of the head commit, removed after the
190
+ review. They never run in your working tree.
191
+ - The canary checks that an engine cannot write files or run shell commands
192
+ before `rh` will use it.
193
+ - `--post` prints the API calls it would make and posts nothing.
194
+
195
+ ## Tests
196
+
197
+ ```text
198
+ python -m unittest discover -s tests
199
+ ```
200
+
201
+ The tests use a fake engine and temporary git repositories. They need git and
202
+ no model, and take a few minutes.
203
+
204
+ ## Contributing
205
+
206
+ See [CONTRIBUTING.md](https://github.com/radarhound/radarhound/blob/main/CONTRIBUTING.md) and [ROADMAP.md](https://github.com/radarhound/radarhound/blob/main/ROADMAP.md).
207
+
208
+ ## Policies
209
+
210
+ - [Privacy](https://github.com/radarhound/radarhound/blob/main/docs/PRIVACY.md): what leaves your machine, and what is stored
211
+ - [Security](https://github.com/radarhound/radarhound/blob/main/docs/SECURITY.md): how to report a vulnerability
212
+ - [Code of conduct](https://github.com/radarhound/radarhound/blob/main/docs/CODE_OF_CONDUCT.md)
213
+
214
+ ## License
215
+
216
+ [MIT](https://github.com/radarhound/radarhound/blob/main/LICENSE)
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "radarhound"
7
+ version = "0.1.0"
8
+ description = "Radarhound: a local code reviewer that investigates the repository and learns from feedback"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ authors = [{ name = "Mohammedsaif Kordia" }]
13
+ requires-python = ">=3.12"
14
+ dependencies = []
15
+ keywords = ["code-review", "llm", "git", "gitlab"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Environment :: Console",
19
+ "Intended Audience :: Developers",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Topic :: Software Development :: Quality Assurance",
24
+ ]
25
+
26
+ [project.urls]
27
+ Homepage = "https://github.com/radarhound/radarhound"
28
+ Repository = "https://github.com/radarhound/radarhound"
29
+ Issues = "https://github.com/radarhound/radarhound/issues"
30
+ Documentation = "https://github.com/radarhound/radarhound/tree/main/docs"
31
+
32
+ [project.scripts]
33
+ rh = "radarhound.cli:main"
34
+ radarhound = "radarhound.cli:main"
35
+
36
+ [tool.setuptools.packages.find]
37
+ include = ["radarhound*"]
38
+
39
+ [tool.setuptools.package-data]
40
+ "radarhound.resources" = ["*.json", "*.md", "*.txt"]
@@ -0,0 +1,3 @@
1
+ """Radarhound: a learning code reviewer (B1a core)."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,129 @@
1
+ """Backlog matching: mark findings already tracked in backlog files (B31).
2
+
3
+ A markdown backlog file holds rows like ``| X50 | <item> | <why> |``.
4
+ ``load_rows`` reads those rows; ``identifiers`` extracts the code-like
5
+ tokens of a text; ``match`` returns the first row sharing enough
6
+ identifiers with a finding.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import re
12
+ from pathlib import Path
13
+
14
+ _ID_RE = re.compile(r"^[A-Z]{0,3}\d+$")
15
+ _BACKTICK_RE = re.compile(r"`([^`]*)`")
16
+ _DOTTED_RE = re.compile(r"[A-Za-z0-9_]+(?:\.[A-Za-z0-9_]+)+")
17
+ _WORD_RE = re.compile(r"\w+")
18
+ _CAMEL_RE = re.compile(r"[a-z]+[A-Z]\w*")
19
+ _PASCAL_RE = re.compile(r"[A-Z][a-z0-9]+[A-Z]\w*")
20
+ _SNAKE_RE = re.compile(r"\w+_\w+")
21
+ _FILE_RE = re.compile(r"\w+\.(?:kt|kts|py|php|ts|js|java|xml|sql)")
22
+
23
+ _EXTS = ("kt", "kts", "py", "php", "ts", "js", "java", "xml", "sql")
24
+
25
+
26
+ def load_rows(root, files):
27
+ """Read backlog rows from ``files`` under ``root``.
28
+
29
+ Every markdown table line ``| <id> | <rest> |`` whose first cell
30
+ (stripped, ``**`` removed) matches ``^[A-Z]{0,3}\\d+$`` becomes
31
+ ``{"id": id, "file": rel, "text": rest}``. Missing or unreadable
32
+ files are skipped silently; header (``| # | ...``) and separator
33
+ (``|---|``) rows never match.
34
+ """
35
+ rows = []
36
+ base = Path(root)
37
+ for name in files or []:
38
+ try:
39
+ text = (base / str(name)).read_text(
40
+ encoding="utf-8", errors="replace")
41
+ except OSError:
42
+ continue
43
+ for line in text.splitlines():
44
+ stripped = line.strip()
45
+ if not stripped.startswith("|") or not stripped.endswith("|"):
46
+ continue
47
+ cells = [cell.strip() for cell in stripped.strip("|").split("|")]
48
+ if len(cells) < 2:
49
+ continue
50
+ first = cells[0].replace("**", "").strip()
51
+ if not _ID_RE.match(first):
52
+ continue
53
+ rest = " | ".join(cells[1:]).strip()
54
+ rows.append({"id": first, "file": str(name), "text": rest})
55
+ return rows
56
+
57
+
58
+ def identifiers(text):
59
+ """Return the lowercased code-like identifier tokens of ``text``.
60
+
61
+ Tokens come from backticked spans (split on non-word characters,
62
+ keeping dotted pairs whole, e.g. ``existingline.quantity``) plus
63
+ code-looking words anywhere: dotted ``a.b``, camelCase
64
+ (``[a-z]+[A-Z]\\w*``), PascalCase with an inner capital
65
+ (``[A-Z][a-z0-9]+[A-Z]\\w*``), snake_case (``\\w+_\\w+``), file
66
+ names (``\\w+\\.(kt|kts|py|php|ts|js|java|xml|sql)``) and their
67
+ stems. Tokens shorter than 4 chars are dropped.
68
+ """
69
+ out = set()
70
+ text = str(text or "")
71
+
72
+ def _add(token):
73
+ lowered = str(token or "").lower()
74
+ if len(lowered) >= 4:
75
+ out.add(lowered)
76
+
77
+ for span in _BACKTICK_RE.findall(text):
78
+ for token in _DOTTED_RE.findall(span):
79
+ _add(token)
80
+ for token in _WORD_RE.findall(span):
81
+ _add(token)
82
+ for token in _DOTTED_RE.findall(text):
83
+ _add(token)
84
+ for pattern in (_CAMEL_RE, _PASCAL_RE, _SNAKE_RE):
85
+ for token in pattern.findall(text):
86
+ _add(token)
87
+ for token in _FILE_RE.findall(text):
88
+ _add(token)
89
+ _add(token.rsplit(".", 1)[0])
90
+ return out
91
+
92
+
93
+ def match(finding, rows, min_shared):
94
+ """Return the first backlog row id matching ``finding``, or None.
95
+
96
+ The finding ids are ``identifiers(title + body + trigger)`` plus
97
+ the stem of ``finding["file"]``. The first row whose identifiers
98
+ share at least ``min_shared`` tokens with the finding, at least
99
+ one of them not the file stem, gives its id. None when ``rows``
100
+ is empty.
101
+ """
102
+ rows = list(rows or [])
103
+ if not rows:
104
+ return None
105
+ try:
106
+ want = int(min_shared)
107
+ except (TypeError, ValueError):
108
+ return None
109
+ finding = finding or {}
110
+ try:
111
+ text = " ".join(
112
+ str(finding.get(key) or "") for key in ("title", "body", "trigger"))
113
+ except Exception:
114
+ text = ""
115
+ found = set(identifiers(text))
116
+ stem = ""
117
+ try:
118
+ stem = Path(str(finding.get("file") or "")).stem.lower()
119
+ except Exception:
120
+ stem = ""
121
+ if stem:
122
+ found.add(stem)
123
+ for row in rows:
124
+ if not isinstance(row, dict):
125
+ continue
126
+ shared = found & identifiers(row.get("text") or "")
127
+ if len(shared) >= want and (shared - {stem} if stem else shared):
128
+ return row.get("id")
129
+ return None