Skip to content

feat(performance): summarize.py prints nearest-rank beside the interpolated percentile and flags a p95 outlier - #5709

Merged
kyle-sexton merged 7 commits into
mainfrom
feat/5660-summarize-nearest-rank
Oct 1, 2026
Merged

kyle-sexton merged 7 commits into
mainfrom
feat/5660-summarize-nearest-rank

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Closes #5660

Summary

plugins/performance/scripts/summarize.py computed percentiles by linear interpolation only, so with few samples one outlier could set p95 with no sign in the output. It now prints the nearest-rank percentile beside the interpolated one and flags a p95 that a single sample moves.

Fix

  • Print the nearest-rank value next to each interpolated percentile.
  • Emit an outlier line naming p95 (and the max sample) when one sample moves it.
  • Stdlib only; no new dependency.
  • Bump the performance plugin to 0.4.0 with a changelog entry and a README update.

Verification

  • bash plugins/performance/scripts/summarize.test.sh passes (24 checks), including the paired interpolated and nearest-rank values, the outlier flag firing, the flag text with and without the max sample, uniform samples not flagged, and a refused p95 having no nearest-rank or outlier line.

Related

🤖 Generated with Claude Code

@kyle-sexton
kyle-sexton marked this pull request as ready for review October 1, 2026 14:31
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-01T14:34:15.658549Z f216df5 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 3m 14s —— View job


Code review complete

  • Gather context (PR diff, changed files)
  • Review summarize.py changes for correctness
  • Review test coverage in summarize.test.sh
  • Review CHANGELOG/README/plugin.json bumps
  • Post findings

I traced the new nearest_rank() and outlier-detection logic by hand against the fixtures in the test suite (20 uniform samples 1–20, and the 19×100ms + 1×5000ms outlier case) and the math checks out: nearest_rank is a correct standard nearest-rank implementation, the paired p50/p95 cells match the test assertions, and the 10%-shift outlier threshold fires and doesn't fire exactly where the tests expect.

One finding posted inline on plugins/performance/scripts/summarize.py (lines 148-156): the OUTLIER line tells the reader to "report the raw samples, not p95," but that branch can fire while refused is False (n ≥ 20), and the actual raw-samples listing is gated behind if refused: — so in the pure-outlier case the script never prints the raw samples it's telling the reader to go check. See the inline comment for a concrete run of the new outlier fixture showing the gap, and two fix options.

Everything else — the percentile_floor/refusal interaction, the CHANGELOG.md/README.md/plugin.json version bump to 0.4.0, and the new test cases (paired values, outlier fires/doesn't-fire, refused-p95-has-no-nearest-rank-or-outlier-line) — looks correct and consistent with the PR description.

Note: I was not able to execute summarize.test.sh or run the script myself in this sandbox (shell execution required approval that wasn't available), so the "24 checks pass" verification claim in the PR body is author-claimed and unverified by me; my analysis above is from reading the code and fixtures by hand, not from running them.

@claude

claude Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 31s —— View job


Security review — PR #5709

Ran /review:security-review against the diff (origin/main...HEAD), scoped to the changed files only.

Changed files:

  • plugins/performance/scripts/summarize.py — adds nearest_rank() and an OUTLIER_SHIFT-based p95 outlier check; purely numeric computation and string formatting over already-loaded samples.
  • plugins/performance/scripts/summarize.test.sh — new test fixtures/assertions, no execution surface changes.
  • plugins/performance/scripts/README.md, plugins/performance/CHANGELOG.md, plugins/performance/.claude-plugin/plugin.json — documentation/version bump only.

Skip gate applied: this change has no security-relevant surface. The diff adds pure numeric computation (nearest_rank, an outlier-shift comparison) and f-string formatting over a list[int] of already-parsed/loaded sample values; it touches no I/O, no path/file handling, no subprocess/command construction, no network calls, no secrets/credentials, and no auth or access-control logic. The existing load() path-resolution and env-var handling this script relies on is unchanged by this PR. No instruction files (CLAUDE.md/AGENTS.md/rules/skills/hooks) are touched, so the instruction-surface-deletion lens doesn't apply either.

Result: no findings. Nothing to post as inline comments.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f216df5872

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@claude

claude Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 49s —— View job


Security review — PR #5709

  • Gather context (PR diff, changed files, head SHA)
  • Run /review:security-review criteria against the diff
  • Check for instruction-surface deletions (CLAUDE.md/AGENTS.md/rules)
  • Post findings (or confirm none)

Ran /review:security-review against origin/main...HEAD (head 0c95f3b), scoped to the 5 changed files.

Skip gate applied: no security-relevant surface.

  • summarize.py — the diff adds nearest_rank() (L77-78) and the p95 outlier check (L148-160): pure numeric computation and f-string formatting over an already-loaded list[int] of millisecond samples. No new I/O, path handling, subprocess/command construction, network calls, secrets, or auth/access-control logic — load()'s path resolution and the env() no-default reads are unchanged by this PR.
  • summarize.test.sh — new fixtures/assertions only, no execution-surface change.
  • README.md, CHANGELOG.md, plugin.json — documentation and version-bump only.
  • No CLAUDE.md/AGENTS.md/rules/skills/hooks files are touched, so the instruction-surface-deletion lens doesn't apply.

I also checked the earlier review threads on this PR: the Codex/claude findings about the OUTLIER line telling the reader to "report the raw samples" without printing them (a correctness/UX gap, not a security issue) are already resolved at this head — L159-160 now prints raw samples whenever refused or outlier, and summarize.test.sh asserts it (test 8).

Result: no security findings. Nothing to post as inline comments.

@claude

claude Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 3m 20s —— View job


Code review complete

  • Gather context (PR diff, changed files, prior review history)
  • Review summarize.py changes for correctness
  • Review test coverage in summarize.test.sh
  • Review CHANGELOG/README/plugin.json bumps
  • Post findings

I reviewed the current head (0c95f3b) against origin/main, which now includes the earlier fix (8a67cae) addressing the Codex/Claude finding from the previous round — summarize.py prints the raw samples whenever OUTLIER fires, not just when refused. That gap is closed.

I hand-checked nearest_rank() and the outlier-shift comparison against the new fixtures in summarize.test.sh (uniform 1–20 samples, the 19×100ms + 1×5000ms outlier case, and the 19-sample refused case): the interpolation/nearest-rank math, the percentile_floor(95.0) gating that keeps the outlier check from firing alongside a refused p95, and the paired p50/p95 cells all match what the tests assert. ab.sh and ratio.py don't parse summarize.py's stdout programmatically, so the new output (nearest-rank suffix, OUTLIER line) doesn't risk breaking a caller.

One finding posted inline on plugins/performance/.claude-plugin/plugin.json:4: the version bump is 0.3.2 → 0.3.3 (patch), but the CHANGELOG.md entry for this release is a ### Added section for new, backward-compatible output (the nearest-rank cell and OUTLIER line) — which, per this plugin's own stated "semantic versioning" convention and its own 0.3.0 precedent (Added → minor bump), should land as 0.4.0. The branch did ship 0.4.0 in f216df5, matching the PR description ("Bump the performance plugin to 0.4.0"), but the later "merge main" commit (0c95f3b) walked it back to 0.3.3 even though origin/main's performance-plugin version hadn't moved from 0.3.2 in the interim — there was no real conflict forcing that renumbering. See the inline comment for the suggested fix.

Everything else — the percentile-floor/refusal interaction, the nearest_rank() arithmetic (floating-point noise in math.ceil(p/100*n) can't cross an integer boundary at this scale, so it's safe), the README wording, and the new test cases — is correct and consistent with the PR description.

Note: I did not execute summarize.test.sh myself; the "24 checks pass" claim in the PR body is author-claimed and unverified by me. My analysis above is from reading the code and fixtures by hand against the test assertions, not from running them.

@claude

claude Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 48s —— View job


Security review — PR #5709

  • Gather context (PR diff, changed files, head SHA)
  • Run /review:security-review criteria against the diff
  • Check for instruction-surface deletions (CLAUDE.md/AGENTS.md/rules)
  • Post findings (or confirm none)

Skip gate applied: this head already has a successful security review that still applies.

The only commit since the last clean security review (at 0c95f3b, which covered summarize.py's nearest_rank() and p95 outlier logic with no findings) is b3a6ca5, which touches only two files:

Both are plain string edits with no execution, I/O, or control-flow effect — this resolves the earlier review's version-bump-vs-CHANGELOG ### Added consistency finding and has no security surface.

No other file in the PR (summarize.py, summarize.test.sh, scripts/README.md) changed in this commit. Those were already reviewed against this diff: pure numeric computation and f-string formatting over an already-loaded list[int] of samples, no I/O, path handling, subprocess/command construction, network calls, secrets, or auth/access-control logic. No CLAUDE.md/AGENTS.md/rules/skills/hooks files are touched by this PR, so the instruction-surface-deletion lens doesn't apply.

Result: no security findings. Nothing to post as inline comments.

@claude

claude Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 58s —— View job


Code review complete

  • Gather context (PR diff, changed files, prior review history)
  • Invoke /review:code-review per repo instructions
  • Post findings as inline comments (or confirm none)
  • Final summary

I reviewed the current head (b3a6ca5) against the 5 changed files, with the lane's criteria (correctness and CLAUDE.md/AGENTS.md alignment; security is scoped to the dedicated security lane, which already ran clean on this PR).

Both findings raised in earlier rounds on this PR are confirmed fixed at this head:

  1. Raw samples not printed when OUTLIER fires alone (Codex + prior claude review on summarize.py:148-158) — fixed in 8a67cae. summarize.py:159-160 now prints raw samples (ms): ... whenever refused or outlier, not just refused. I hand-traced this against the 20-sample outlier fixture (19×100 + 1×5000) in summarize.test.sh lines 85-94 — the assert_contains "the flag is followed by the raw samples" "raw samples (ms): 100 100" "$RUN_OUT" assertion matches the current code path.
  2. Version bump inconsistent with the ### Added changelog entry (prior claude review on plugin.json) — fixed in b3a6ca5. plugin.json:4 and the CHANGELOG.md heading both now read 0.4.0, one minor step above origin/main's 0.3.2, consistent with this plugin's own semver convention and its 0.3.0 Added-entry precedent. The intervening 0c95f3b merge-and-release-0.3.3 commit only touched unrelated files pulled in from main (confirmed via git show 0c95f3b --stat — performance/.claude-plugin/plugin.json and CHANGELOG.md are the only performance-plugin files it touched, and b3a6ca5 is a 2-file, 2-line fix on top of it).

I also re-checked nearest_rank() (summarize.py:77-78) and the outlier-shift comparison (summarize.py:148-158) by hand against all 10 cases in summarize.test.sh (paired interpolated/nearest-rank values, the outlier fixture, the uniform control, and the refused-p95-has-no-nearest-rank-or-outlier-line case) — the arithmetic and gating match what the tests assert. README.md's table-row update and the CHANGELOG.md entry text are accurate to the shipped behavior.

No new findings — nothing to post as inline comments.

Note: I could not execute bash plugins/performance/scripts/summarize.test.sh myself in this sandbox (shell execution required approval that wasn't available), so the "24 checks pass" claim in the PR body is author-claimed and unverified by me. My analysis above is from reading the code and test fixtures by hand, not from running them.
· branch feat/5660-summarize-nearest-rank

@claude

claude Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 5s —— View job


Security review — PR #5709

  • Gather context (PR diff, changed files, head SHA)
  • Run /review:security-review criteria against the diff
  • Check for instruction-surface deletions (CLAUDE.md/AGENTS.md/rules)
  • Post findings (or confirm none)

Skip gate applied: this head already has a successful security review that still applies.

The only commit since the last clean security review (at b3a6ca5, which covered summarize.py's nearest_rank() and p95 outlier logic with no findings) is 9e0a4fe, a merge of origin/main into this branch. I confirmed git diff b3a6ca5..9e0a4fe --stat -- plugins/performance is empty — the merge pulled in ~195 unrelated files from main (docs-naming plugin extraction, testing/autonomy/context-guard prerequisite scaffolding, CI workflow tweaks, etc.) and touched none of this PR's files. gh pr diff 5709 confirms the PR's actual diff against main is still scoped to the same 5 files as before:

  • plugins/performance/scripts/summarize.py — nearest_rank() (L77-78) and the p95 outlier check (L148-160), byte-identical to the previously reviewed version: pure numeric computation and f-string formatting over an already-loaded list[int] of samples. No I/O, path handling, subprocess/command construction, network calls, secrets, or auth/access-control logic — load()'s path resolution and the env() no-default reads are unchanged.
  • summarize.test.sh, README.md, CHANGELOG.md, plugin.json — test fixtures and documentation/version-bump only, also unchanged since the last review.

No CLAUDE.md/AGENTS.md/rules/skills/hooks files are touched by this PR (the merge brings in edits to other repos' skill/rule files on main, but none are part of this PR's diff), so the instruction-surface-deletion lens doesn't apply.

Result: no security findings. Nothing to post as inline comments.
· branch feat/5660-summarize-nearest-rank

@claude

claude Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 44s —— View job


Code review complete

  • Gather context (PR diff, prior review history, CLAUDE.md/AGENTS.md)
  • Check skip gate (already-reviewed head)
  • Review changed files for correctness and convention alignment
  • Post findings (or confirm none)

Skip gate applied: this head already has a successful review from this lane that still applies.

git diff b3a6ca5..9e0a4fe -- plugins/performance/ is empty — the only commit since the last clean code review (b3a6ca5, which found no new issues after the raw-samples and version-bump fixes landed) is 9e0a4fe, a merge of origin/main that pulls in five unrelated commits (927a530, 2b7e026, 5408910, 549d540, 0d6ffa6) touching planning, testing, docs-naming, claude-ops, and plugin jq declarations — none of which touch plugins/performance/.

The diff between origin/main and HEAD for the 5 PR files (plugin.json, CHANGELOG.md, scripts/README.md, scripts/summarize.py, scripts/summarize.test.sh) is byte-identical to what was already reviewed at b3a6ca5:

  • Both earlier findings are confirmed fixed and stable: raw samples now print whenever OUTLIER fires (summarize.py L159-160), and the version bump is 0.4.0 consistent with the ### Added changelog entry and this plugin's semver convention.
  • nearest_rank() and the outlier-shift check continue to match all cases in summarize.test.sh (paired values, the outlier fixture, the uniform control, the refused-p95 control).

No new findings — nothing to post.

@kyle-sexton
kyle-sexton merged commit 17544a1 into main Oct 1, 2026
3 checks passed
@kyle-sexton
kyle-sexton deleted the feat/5660-summarize-nearest-rank branch October 1, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(performance): summarize.py prints nearest-rank beside the interpolated percentile and flags an outlier that moves p95

1 participant