Repository navigation
ci: handle renamed files in the unslop gate's baseline diff - #9
Conversation
A renamed file's head path does not exist at the base commit, so the old base-scan skipped it and treated every pre-existing gateable finding in that file as newly introduced. Materialize each changed file's base content (resolved through the git rename map) at its head path in a temporary base tree so base and head dedupe keys compare like for like. Also strip the @file:line location from clone messages so the dedupe key stays stable regardless of which representative file unslop picks when the base and head scan sets differ.
When BASHPID is unavailable the subshell-vs-parent lock leg was skipped, but the final pass still claimed the parent-hold guarantee, overstating coverage. Move the full-coverage pass into the executed branch and give the skip branch an honest skip-aware message.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe unslop workflow now reconstructs base contents at head paths, maps renamed files, preserves copied-file behavior, and normalizes finding keys. The lock test updates messages for environments without ChangesUnslop workflow reporting
Lock test output
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The CI gate improves renamed-file handling and keeps analyzer failures non-blocking, while the related test output remains truthful. No actionable merge-blocking risk remains after normal checks and review. Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Intent
Add a changed-files unslop CI gate to firstmate (.github/workflows/unslop.yml) that catches newly introduced AI slop without flagging pre-existing findings. Gate only supported JS/TS files a PR changes (diff against base branch), not the whole repo; no-op pass when no code files changed. Baseline ratchet: fail the build ONLY on error-tier gateable findings the PR newly introduces; pre-existing error-tier findings stay report-only even in touched files. An unslop execution failure or unreadable report is announced loudly in the job log but does NOT block the pull request (non-blocking); no oxlint runtime-failure enforcement. Keep it fast: changed-files scope, pinned analyzers [email protected] and [email protected], cached npm. Renamed files must not break the base-report diff: resolve each changed file base path through the git rename map and scan pre-rename content at the head path so base/head dedupe keys compare like for like; the dedupe key must be stable regardless of which representative file unslop picks. CONTRIBUTING.md documents the gate and its non-blocking analyzer-failure behavior. Ship through no-mistakes and resolve all actionable CodeRabbit review threads on the PR.
What Changed
HEAD_SHA, reads the pre-rename content from the base commit withgit show, and writes it at the head path in a synthetic base tree (replacing thegit worktree addcheckout), so base and head dedupe keys compare like for like for renamed files.@...>location annotations from finding messages with agsub, so the key stays stable regardless of which representative file unslop reports.BASHPID), so the skipped leg is visible in the result instead of over-claiming a full pass.Risk Assessment
✅ Low: Both prescribed fixes are applied and verified by live simulation (rename-map loop in a scratch repo, gsub via jq); the change is confined to one workflow file plus a truthful test-message tweak, and all source-verifiable intent criteria are satisfied.
Testing
Ran the changed wake-queue shell test (all pass) and end-to-end exercised the actual workflow gate scripts with the pinned analyzers in a scratch repo across seven scenarios covering rename dedupe, pre-existing report-only behavior, new-slop blocking, no-code skip, non-blocking analyzer failure, and before/after regression proofs for both fixed bugs; every scenario produced the intended exit code and log output.
Evidence: Gate simulation transcript (rename, pre-existing, new-slop, no-code, analyzer-fail, old-script regression)
Source: Gate simulation transcript (rename, pre-existing, new-slop, no-code, analyzer-fail, old-script regression)
Evidence: Dedupe-key line-shift transcript (new script passes, old script false-fails)
Source: Dedupe-key line-shift transcript (new script passes, old script false-fails)
Evidence: Repeatable E2E driver script
Source: Repeatable E2E driver script
Evidence: Repeatable line-shift driver script
Source: Repeatable line-shift driver script
Evidence: Key rename-scenario outcome
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
🔧 **Rebase** - 1 issue found → auto-fixed ✅
.github/workflows/unslop.yml- merge conflict rebasing onto origin/main🔧 Fix applied.
✅ Re-checked - no issues remain.
🔧 **Review** - 2 issues found → auto-fixed ✅
.github/workflows/unslop.yml:140- The rename-map loop readsgit diff --name-status -z "$BASE_SHA...$HEAD_SHA", but the "Report findings and gate" step's env block (lines 78-79) defines only BASE_SHA; HEAD_SHA exists only in the first step's env (line 24). The script runs underset -euo pipefail, and an unbound variable inside a process substitution kills only the subshell: bash prints 'HEAD_SHA: unbound variable' to the log, the while loop reads nothing, and the parent script continues (reproduced locally). Result: base_path_for is always empty, renamed files fall back to their head path,git cat-file -e "$BASE_SHA:$rel"fails for them, they are excluded from the base scan, and their pre-existing error-tier findings are reported as newly introduced — the exact false CI failure this commit claims to durably fix, and a required behavior in the user intent ('Renamed files must not break the base-report diff'). Fix: addHEAD_SHA: ${{ github.event.pull_request.head.sha }}to the step env at line 79. Optional hardening: write the name-status diff to a file first (as the first step does for name-only) so a git failure is loud instead of silently yielding an empty map..github/workflows/unslop.yml:112-gsub("@[^>]*"; "")strips from any '@' to the next '>' or to end-of-message. unslop 0.1.7's message templates always bracket the representative token (<name@file:line>,<function@%d>), sogsub("@[^>]*>"; ">")would normalize the same tokens while not consuming an unbracketed '@' (e.g. a decorator or package@version quoted in a message) plus all trailing text. The current form can only over-collapse dedupe keys, letting a genuinely new finding dedupe against an unrelated pre-existing one (false negative; it can never falsely block). Low risk given observed templates; tightening is a safe mechanical hardening.🔧 Fix: bind HEAD_SHA in gate step; tighten dedupe-key gsub
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-wake-queue.test.sh (full file, all tests pass including the changed self-held-lock test)End-to-end simulation: extracted the realrunscripts from .github/workflows/unslop.yml (target commit dc48fe5) and executed them against a scratch git repo with pinned [email protected] and [email protected] on PATHScenario rename: pre-existing exact-clone slop, one clone half renamed (R100) + partner touched → gate exit 0 (pre-existing finding correctly deduped through the rename map)Scenario preexisting: both slop files touched in place, no rename → gate exit 0 (report-only)Scenario newslop: PR adds a new duplicated-code pair → gate exit 1 with ::error annotationScenario nocode: markdown-only change → has_code=false, gate step skippedScenario analyzer-fail: unslop replaced with a crashing stub → gate exit 0 with loud ::error (non-blocking)Regression proof: the base-commit (63ca758) gate script run on the same rename scenario exits 1 (false positive) — fails before the fix, passes afterDedupe-key stability proof: clone start line shifted two lines → new script (with gsub) exits 0, old script exits 1 on the line-number-bearing keyVerified CONTRIBUTING.md documents the gate and its non-blocking analyzer-failure behavior✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
Summary by CodeRabbit
Bug Fixes
Tests