feat(ruff-format): disclose Ruff rewrites on the user channel - #2472
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
fead8e3 to
9a16fa1
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9a16fa18f5
ℹ️ 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".
48607ff to
15f2ac2
Compare
|
Claude finished @kyle-sexton's task in 1m 39s —— View job Security Review
Scope: No security issues found. The added logic:
Checked specifically for:
One functional (non-security) issue was already flagged by the automated Codex review on this PR — a mixed-result run (mutation + a residual finding) can emit two concatenated JSON documents on stdout instead of one, since this block's
|
Partially addresses #1596 Co-authored-by: Kyle Sexton <kyle-sexton@users.noreply.github.com>
15f2ac2 to
1a85ed4
Compare
|
Claude finished @kyle-sexton's task in 1m 6s —— View job Security Review
Scope: No security issues found. Analysis of the added block (lines 230–241):
Specifically checked:
Note (non-security, not re-reported here): the existing Codex review and the prior Claude run both flagged that a mixed-result run (mutation + a residual finding) emits two concatenated JSON documents on stdout (this block's |
|
Claude finished @kyle-sexton's task in 2m 21s —— View job Code Review
Scope: 🔴 Important — inline comment postedPosted at ruff-format.sh:238: the new 🟡 Suggestion — test coverage gap for the new feature
Everything else in this PR — the version bump and |
| (cd "$RUN_DIR" && "$RUFF_BIN" format "${RUFF_COMMON[@]}" "$RUFF_ARG") >/dev/null 2>&1 || true | ||
| if [[ -n "$_ruff_before" ]]; then | ||
| if ! cmp -s "$_ruff_before" "$FILE" 2>/dev/null; then | ||
| hook::emit_system_message "ruff-format: auto-fixed and/or reformatted $(basename "$FILE") via Ruff." |
There was a problem hiding this comment.
🔴 Important — mixed-result runs emit two JSON documents on stdout
hook::emit_system_message (via hook::emit_channels) prints a complete JSON document here, immediately after the fix/format pass. But when the file is also mutated and the verify pass below still has residual findings, hook::ctx_flush at line 267 (or the tool-break path at line 291) prints a second JSON document on the same stdout stream.
hook::emit_channels's own doc comment (hook-utils.sh:78-80) states the invariant this breaks: "CC parses the hook's whole stdout as a single JSON doc, so a run that has both lint findings and a pending skip notice must compose them here rather than print twice." This is exactly that case — mutation notice + advisory findings — and it's a common one: Ruff frequently reformats a file while still leaving an unfixable diagnostic (e.g. F821, or the F401 this hook deliberately makes unfixable).
Sibling plugins follow the single-emission-point convention to avoid this: bash-format.sh accumulates into NOTICE/CTX and calls hook::emit_channels exactly once at the end (bash-format.sh:284-289), and markdown-format.sh/typos-format.sh do the same (hook::emit_channels PostToolUse "$CTX" "$SYSMSG"). This PR's hook::emit_system_message call should instead stash the mutation notice in a variable (e.g. $SYSMSG) and let it flow into the existing hook::ctx_flush/exit-0 paths below so only one JSON document is ever printed per run.
This was already flagged by the automated Codex review on this PR (P1) — confirming it here since it's a genuine correctness bug, not just a style nit: a mixed-result run can corrupt/drop the hook's structured output for the consumer.
|
Claude has reviewed this PR 1 time. The lane skips further automatic reviews after 5; deleting this comment resets the count. |
No linked issue
Partially addresses #1596
Related
Refs #1596