feat(githooks): docstring scanner leg B, date-gated touched ratio - #1104
Merged
Merged
Conversation
Adds leg B to `.githooks/docstring-scan.sh --check`: documented / (documented + undocumented) over ALL touched (added + modified, never skipped) functions below DOCSTRING_THRESHOLD (default 80) is a violation — the question CodeRabbit's Docstring Coverage check asks. Leg A (an added undocumented function blocks) is unchanged. Phase-in uses the self-flipping gate shape of scripts/check-docs-presence.sh: ENFORCE_DOCSTRINGS_FROM (default 2026-11-01, owner ruling 2026-10-01) and a DOCS_TODAY seam. Before the cutoff a leg-B violation is a WARN line on stderr and leaves the exit code alone; on/after it, --check exits 1. Malformed dates or threshold exit 2, so a bad value cannot silently disarm the gate. Zero touched functions give no leg-B verdict, said explicitly. The verdict is decided in integers (d*100 < T*n), so exactly the threshold passes. SUMMARY gains `threshold=T legb=pass|fail|n/a`, appended at the end only; the one known consumer (the ~/.claude docstring Stop hook) drops SUMMARY and reads only added/undocumented rows, and runs without --check. Tests: leg-A assertions now run with leg B disarmed (threshold 0) so they do not flip on the cutoff date; new leg-B fixtures cover before/on/after the cutoff, exactly 80%, 79.17%, zero touched, skipped-in-either-direction, and malformed configuration. Two known-answer controls (fetched by full SHA, unfetchable = FAILURE) match CodeRabbit's verdicts: panll#136 and nextgen-databases#107 both measure 2 of 22 touched functions documented. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hw7qg3u9PAP6b2oKyVTSVC
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 56 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (2)
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 |
hyperpolymath
enabled auto-merge (squash)
October 1, 2026 13:30
Contributor
|
Autopilot could not be updated. Open Coding to check access and billing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds leg B to the canonical docstring scanner
.githooks/docstring-scan.sh(#1073):DOCSTRING_THRESHOLD(default 80) is a violation. This is the ratio CodeRabbit's Docstring Coverage check reports.scripts/check-docs-presence.sh(valid_date/require_date, plus aDOCS_TODAYseam).ENFORCE_DOCSTRINGS_FROMdefaults to 2026-11-01 (owner ruling 2026-10-01). Before the cutoff, a leg-B violation under--checkprints aWARN leg Bline on stderr and leaves the exit code unchanged. From the cutoff date onward,--checkexits 1.--checkexit 1.legb=n/a, and under--checkthe scanner says so on stderr. A vacuous ratio counts as neither a pass nor a fail.ENFORCE_DOCSTRINGS_FROMorDOCS_TODAY, or aDOCSTRING_THRESHOLDthat is not an integer 0-100, exits 2 in every mode. A bad value cannot silently disarm the gate.d*100 < T*n, so exactly 80% passes and 79.17% fails.threshold=T legb=pass|fail|n/a, appended at the end only. The one consumer I found is the~/.claudedocstring Stop hook. It drops the SUMMARY line, reads onlyadded/undocumentedTSV rows, and runs without--check, so this PR changes nothing for it. Nothing in this repo parses SUMMARY apart from the test suite.Tests (
scripts/tests/docstring-scan-test.sh): 72 passed, 0 failed locally. The fullrun-shell-test-suite.shpassed all 63 files.DOCSTRING_THRESHOLD=0). Without that, "editing an undocumented legacy body does not block" would flip red on 2026-11-01.ENFORCE_DOCSTRINGS_FROMoverride--check: rc 0hyperpolymath/panll964f9563..61141fb3gives 2 documented of 22, legb=fail.hyperpolymath/nextgen-databasesfc12a2eb..e12e4c71gives 2 documented of 22, legb=fail.Mutants (run through the
SCANNER=seam; each passedbash -nand differed from the original undercmp)-lt→-le<→>A planted bad calibration SHA reds the control as
commits present … absent. shellcheck is clean, and both files stay 0755.🤖 Generated with Claude Code
https://claude.ai/code/session_01Hw7qg3u9PAP6b2oKyVTSVC