Skip to content

Commit 099eec1

Browse files
BBufclaude
andauthored
sglang-humanize-review: add PR comprehension pass, exhaustive corpus sweep, and off-diff verification (#69)
Extend the review skill so a review now: 1. Opens with a mandatory PR comprehension pass — a change summary plus a Mermaid execution flowchart (changed nodes marked) with a prose walkthrough after each diagram, shown before any findings. Includes Mermaid syntax-safety rules (quote special-char labels, <br/> not \n) and vertical-stacking guidance so it renders on GitHub's pinned Mermaid. 2. Grounds findings in an exhaustive, memory-bounded sweep of the whole review corpus (new summarize_sglang_review_corpus.py) instead of the first-N matches, with a written historical-review synthesis before the findings. 3. Requires any claim depending on code outside the diff (call-site coverage, method shadowing, "no other caller", line numbers) to be verified against the PR branch, not a local checkout — preventing confident false positives. Validated by running the full pipeline on 50 randomly sampled merged PRs from the last 6 months: surfaced 3 independently confirmed latent bugs plus several candidates, with no unverified false positives in the final report. Tests updated accordingly (8 passing). Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent d45b5cc commit 099eec1

4 files changed

Lines changed: 491 additions & 16 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ find it.
4343
| [`llm-torch-profiler-analysis`](skills/llm-torch-profiler-analysis/) | You need a three-table profiler report that keeps `extend/prefill` and `decode` evidence separate. |
4444
| [`llm-pipeline-analysis`](skills/llm-pipeline-analysis/) | You need forward-pass, layer, and kernel-level timing from a torch profiler trace, including anchor boundaries and Perfetto ranges. |
4545
| [`model-compute-simulation`](skills/model-compute-simulation/) | You need operator shapes, FLOPs, MFU estimates, kernel-to-op mapping, or parallelism what-if analysis for an LLM serving shape. |
46-
| [`sglang-humanize-review`](skills/sglang-humanize-review/) | You need SGLang code-review findings grounded in full human PR review episodes from project start through the latest refresh (June 2026), including inline code context, top-level discussion, review summaries, and multi-round replies. |
46+
| [`sglang-humanize-review`](skills/sglang-humanize-review/) | You need SGLang code-review findings grounded in full human PR review episodes from project start through the latest refresh (June 2026), including inline code context, top-level discussion, review summaries, and multi-round replies. Every review opens with a PR comprehension pass — a change summary plus a Mermaid execution flowchart with the diff's modified steps marked — so the reviewer sees how the PR runs before the findings. |
4747
| [`sglang-sota-humanize-loop`](skills/sglang-sota-humanize-loop/) | You want one model-level Humanize RLCR loop that owns gap decisions, profiler triage, required layer-pipeline deep dives, SGLang patches, optional `ncu-report-skill` evidence, and real-model revalidation after the fixed fair benchmark. |
4848
| [`vllm-sota-humanize-loop`](skills/vllm-sota-humanize-loop/) | You want one model-level Humanize RLCR loop that owns gap decisions, profiler triage, required layer-pipeline deep dives, vLLM patches, optional `ncu-report-skill` evidence, and real-model revalidation after the fixed fair benchmark. |
4949
| [`sglang-prod-incident-triage`](skills/sglang-prod-incident-triage/) | You need to turn queue growth, timeouts, wrong outputs, crashes, or distributed stalls into a replay and next debug step. |

skills/sglang-humanize-review/SKILL.md

Lines changed: 155 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ description: "Perform SGLang code review in the style of human maintainers by co
1010
Use this skill when the user asks for a human-style SGLang code review or wants
1111
review feedback that resembles SGLang maintainers instead of generic linting.
1212

13+
Every review opens with a **PR comprehension pass**: a short change summary plus
14+
a Mermaid execution flowchart (with the PR's added/modified steps marked) so the
15+
reviewer can see how the diff actually runs before reading any findings. See
16+
[PR Comprehension Diagram](#pr-comprehension-diagram).
17+
1318
The bundled corpus is collected from `sgl-project/sglang` PRs from the first
1419
public PR through the latest refresh (June 2026), excluding PRs authored by bots
1520
or obvious coding-agent accounts. The collector paginates every PR's full
@@ -27,11 +32,38 @@ review episodes, not just individual comments:
2732
Every episode preserves PR metadata, reviewer identity, original comment text,
2833
original comment language, timestamps, categories, and multi-round replies when
2934
GitHub exposes them. Read [references/corpus-summary.md](references/corpus-summary.md)
30-
first for coverage, counts, top paths, and category distribution. Do not load
31-
the gzip corpus directly into context; query it with the helper script.
35+
first for coverage, counts, top paths, and category distribution. Do not paste
36+
the raw gzip corpus into context; go through the helper scripts, which read it
37+
in memory-bounded segments and return a digest.
3238

3339
## Corpus Tools
3440

41+
There are two tools. **For an actual PR review, the exhaustive sweep below is
42+
mandatory** (see workflow step 3); the first-N query tool is only for follow-up
43+
drill-downs.
44+
45+
### Exhaustive sweep + synthesis (run this first, for every review)
46+
47+
`summarize_sglang_review_corpus.py` scans the **whole** corpus in
48+
memory-bounded segments, collects **every** thread relevant to the PR (not just
49+
the first N), and prints an aggregate over all matches plus the top relevance-
50+
ranked review opinions. Pass every touched path and the PR's risk keywords;
51+
`--path` and `--query` are repeatable and OR-combined.
52+
53+
```bash
54+
python3 skills/sglang-humanize-review/scripts/summarize_sglang_review_corpus.py \
55+
--path python/sglang/srt/speculative --path python/sglang/srt/managers \
56+
--query eagle --query "cuda graph" --query verify --query logprob \
57+
--top 30
58+
```
59+
60+
It reports `Scanned N threads ... matched M threads across K PRs` so coverage is
61+
explicit. Read the aggregate and the top-ranked threads, then write a short
62+
synthesis of the recurring historical review opinions before reviewing. Use
63+
`--format jsonl` to stream all matched threads when you need to read every one.
64+
65+
### First-N lookup (follow-up drill-down only)
66+
3567
Search the corpus by topic, path, category, or reviewer:
3668

3769
```bash
@@ -84,15 +116,28 @@ python3 skills/sglang-humanize-review/scripts/collect_sglang_review_corpus.py \
84116
maintainer-level summaries.
85117
- Preserve the original language of any relevant corpus examples; do not
86118
translate user-facing comments unless the user asks.
87-
3. Query similar review threads.
88-
- Search by path first for touched SGLang modules.
89-
- Search by risk keyword next, for example `cuda`, `kv cache`,
90-
`server_args`, `openai`, `logprob`, `tp`, `dp`, `eagle`, `fp8`,
91-
`benchmark`, or `pytest`.
92-
- Query at least one non-inline source (`--kind pr_conversation` or
93-
`--kind review_submission`) when the PR changes behavior, tests, docs,
94-
benchmarking, deployment defaults, or model support.
95-
- Prefer evidence from the same subsystem over broad keyword matches.
119+
3. Exhaustively sweep the corpus, then synthesize the historical review
120+
opinions. This step is **mandatory and must finish before you write any
121+
findings** — do not review off the first few hits.
122+
- Run `summarize_sglang_review_corpus.py` with **every touched path**
123+
(`--path`, repeatable) and the PR's risk keywords (`--query`, repeatable:
124+
for example `cuda`, `kv cache`, `server_args`, `openai`, `logprob`, `tp`,
125+
`dp`, `eagle`, `fp8`, `benchmark`, `pytest`). It scans all threads in
126+
memory-bounded segments and aggregates every relevant match, not the first
127+
N.
128+
- Confirm coverage from its `Scanned N ... matched M across K PRs` line. If
129+
`matched` is 0, widen paths/keywords and rerun; if it is very large, read
130+
the aggregate plus the top-ranked threads and, when needed, stream the
131+
full set with `--format jsonl`.
132+
- Read the matched threads — especially at least one non-inline source
133+
(`pr_conversation` or `review_submission`) when the PR changes behavior,
134+
tests, docs, benchmarking, deployment defaults, or model support — and
135+
**write a short synthesis**: the recurring concerns, what reviewers
136+
blocked vs. nitpicked, repros/benchmarks they demanded, and the prevailing
137+
resolution for this subsystem. Prefer same-subsystem evidence over broad
138+
keyword matches. This synthesis is what the findings must be grounded in.
139+
- Use `query_sglang_review_corpus.py` only afterward, to drill into a
140+
specific thread or reviewer surfaced by the sweep.
96141
4. Add cross-skill evidence when the diff touches an area covered elsewhere in
97142
this repository.
98143
- Model-family implementation or optimization: query
@@ -105,13 +150,34 @@ python3 skills/sglang-humanize-review/scripts/collect_sglang_review_corpus.py \
105150
expectations for startup logs and capacity accounting.
106151
- Serving incidents, hangs, or distributed regressions: use
107152
`sglang-prod-incident-triage` style replay requirements.
108-
5. Produce a code-review response.
153+
5. Explain the PR before judging it (PR comprehension pass).
154+
- This step is mandatory and always comes **before** any review findings.
155+
- Goal: let a reviewer grasp *what changed* and *how the changed code runs*
156+
in under a minute, without reading the whole diff.
157+
- Produce a short prose summary plus a Mermaid diagram, following the
158+
[PR Comprehension Diagram](#pr-comprehension-diagram) contract below.
159+
- Trace the actual execution path through the changed lines: entrypoint,
160+
control flow, data flow, the modified branches/calls, and where the new
161+
behavior diverges from the old one. Highlight changed nodes.
162+
- Read enough surrounding code (callers, callees, config wiring) to make the
163+
flow correct. Do not invent functions or call edges that are not in the
164+
diff or the files it touches.
165+
6. Produce a code-review response.
109166
- Lead with concrete findings ordered by severity.
110167
- Include file and line references from the reviewed diff.
111168
- Explain the failure mode, not just the preferred style.
112169
- Suggest a fix or validation step when the issue is actionable.
113170
- Keep nits separate from correctness, performance, or compatibility risks.
114-
6. If no issue is found, say so clearly.
171+
- **Verify any claim that depends on code outside the diff against the PR
172+
branch, not a local checkout.** Findings about call-site coverage, method
173+
shadowing/MRO, "no other caller", or exact line numbers are base-sensitive:
174+
a local repo on a different commit produces confident false positives
175+
(e.g. grepping a stale `EagleVerifyInput` for a method-collision that does
176+
not exist on the PR branch). Confirm with `gh pr diff`, `gh api
177+
.../contents/<path>?ref=<pr-sha>`, or `git show <pr-sha>:<path>`. If only a
178+
mismatched checkout is available, label the finding "needs branch
179+
verification" rather than asserting it.
180+
7. If no issue is found, say so clearly.
115181
- Mention the main residual risk and the test or benchmark coverage that
116182
would increase confidence.
117183

@@ -144,6 +210,71 @@ threads in the corpus:
144210
- **Observability**: review metrics, logs, warning levels, traceability, and
145211
error messages when operational behavior changes.
146212

213+
## PR Comprehension Diagram
214+
215+
Before findings, emit a comprehension block so the reviewer understands the
216+
PR's principle at a glance. It has two parts:
217+
218+
1. **Change summary (2-6 bullets).** Plain language: what subsystem is touched,
219+
the core mechanism the PR changes, and the one or two lines that carry the
220+
real behavior change. Name the entrypoint(s) and the touched files.
221+
2. **A Mermaid flowchart** of the execution logic for the PR-relevant path,
222+
with changed steps visually marked, **each diagram immediately followed by a
223+
prose walkthrough of its details**.
224+
225+
Diagram rules:
226+
227+
- Use a fenced ` ```mermaid ` block with `flowchart TD` (or `LR` for short
228+
linear flows). This renders on GitHub PR comments and most markdown viewers.
229+
- Model the **runtime execution path**, not the file tree: entrypoint → control
230+
flow (branches/loops) → the calls and data transforms the PR adds or changes →
231+
return/side-effect. The reader should see how a request/tensor/batch actually
232+
flows through the changed code.
233+
- Mark nodes the PR adds or modifies with the `changed` class and keep
234+
untouched context nodes plain, so old vs. new behavior is obvious. Always
235+
include the legend node.
236+
- Annotate edges with the condition or data that flows along them
237+
(`-->|fp8 path|`, `-->|cache miss|`) when a branch is where the behavior
238+
changes.
239+
- Keep it to roughly 6-14 nodes. If the PR spans independent code paths, emit
240+
one small flowchart per path as **separate ` ```mermaid ` blocks**, stacked
241+
vertically (one after another, never two side by side) — do not pack two
242+
`subgraph`s into one block, which lays them out horizontally and shrinks each
243+
to an unreadable size. For a pure refactor with no control-flow change, show
244+
old-vs-new as two short branches and say so.
245+
- Prefer `flowchart TD` (top-down) so the graph grows vertically and stays
246+
legible; reserve `LR` for a genuinely short linear chain.
247+
- Immediately after each diagram, add a short prose walkthrough of *that*
248+
diagram: what the entrypoint is, what each branch/condition means, and which
249+
nodes the PR changed and why. The picture orients; the walkthrough is what
250+
the reviewer reads. Never drop a diagram without explaining it.
251+
- Reference real symbols (`function`, `ClassName.method`, file:line) in node
252+
labels so the diagram is verifiable against the diff. Do not fabricate edges.
253+
- Syntax safety, so the block renders on GitHub's pinned Mermaid, not just the
254+
latest CLI: wrap any node or edge label containing `()`, `,`, `:`, `=`, `>`,
255+
`&`, or `/` in double quotes — `C["down_proj(x, skip_all_reduce=rs)"]`,
256+
`B -->|"id < 0 or id >= vocab"| N`. Use `<br/>` for line breaks inside a
257+
label, never a literal `\n`. Put `classDef changed stroke-dasharray:5 5,stroke-width:2px;`
258+
once at the end. Quoting unconditionally is the safe default.
259+
260+
Skeleton to adapt (replace labels with the PR's real symbols and paths):
261+
262+
```mermaid
263+
flowchart TD
264+
A["Entry: forward / handler / scheduler step"] --> B{"Branch the PR changes"}
265+
B -->|"new condition"| C["New/changed call or transform"]:::changed
266+
B -->|"existing path"| D["Unchanged path"]
267+
C --> E["Downstream effect: KV write / output / metric"]:::changed
268+
D --> E
269+
E --> F["Return / response / side effect"]
270+
271+
L["Legend: dashed border = added or modified by this PR"]:::changed
272+
classDef changed stroke-dasharray:5 5,stroke-width:2px;
273+
```
274+
275+
Place this comprehension block first in the response, then the findings. Keep
276+
it tight; it orients the reader, it is not the review itself.
277+
147278
## Review Style
148279

149280
Mirror human SGLang review habits:
@@ -164,13 +295,23 @@ Mirror human SGLang review habits:
164295

165296
For a normal review, return:
166297

167-
- Findings first, ordered by severity, with file/line references.
298+
- A PR comprehension block first: change summary plus the Mermaid execution
299+
flowchart(s) with changed nodes marked, each diagram followed immediately by
300+
a prose walkthrough of its details (see
301+
[PR Comprehension Diagram](#pr-comprehension-diagram)).
302+
- A short **historical review synthesis** next: state the sweep coverage
303+
(`scanned / matched / PRs`) and summarize the recurring review opinions for
304+
this subsystem from the exhaustive corpus sweep (workflow step 3) that the
305+
findings build on.
306+
- Findings next, ordered by severity, with file/line references, explicitly
307+
grounded in that synthesis where a precedent applies.
168308
- Open questions or assumptions.
169309
- Test or benchmark gaps.
170310
- A short summary only after findings.
171311

172312
For a review-prep pass before the user opens a PR, return:
173313

314+
- the PR comprehension block (change summary plus Mermaid execution flowchart)
174315
- likely reviewer concerns
175316
- missing tests or benchmark evidence
176317
- suggested patch cleanup

0 commit comments

Comments
 (0)