Skip to content

feat(githooks): canonical docstring scanner with a known-answer suite - #1073

Open
hyperpolymath wants to merge 1 commit into
mainfrom
feat/docstring-scan
Open

hyperpolymath wants to merge 1 commit into
mainfrom
feat/docstring-scan

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

Arm 0 of the docstring-coverage cure. Adds .githooks/docstring-scan.sh, the estate's single docstring predicate, plus its fixture suite scripts/tests/docstring-scan-test.sh.

  • Modes: --worktree (for the Stop hook), --staged (pre-commit) and --range BASE..HEAD (CI and calibration).
  • --check: exits 1 only when a newly-added function has no docstring. An undocumented function that already existed and was only edited is reported but does not block.
  • Output: one TSV row per touched function, then a SUMMARY line that always prints the denominator.
  • Scope: tier 1 is shell. Any other source file is reported as skipped, never as documented.

Why

CodeRabbit's "Docstring Coverage" warning keeps firing across the estate. Shell is the language it has been proven to parse, and the shell baseline is 0.00%. Two consumers still to come will both call this scanner: the Claude Stop hook and a .githooks validator.

Verification

  • bash scripts/tests/docstring-scan-test.sh passes 30/30.
  • It calibrates against a known answer, PR feat(rulesets): base protection floor applier, branch + tag #1034 at 1cc72cdc80c9: 2 files, 13 functions, 0.00% coverage, 3 skipped. self-test.yml already checks out with fetch-depth: 0, so that commit is reachable in CI.
  • These mutants were each killed:
    • a shellcheck directive counted as a docstring;
    • a heredoc body treated as code;
    • untracked files dropped;
    • a trailing comment counted as a docstring;
    • a deleted fixture docstring, which fails exactly one assertion.

🤖 Generated with Claude Code

https://claude.ai/code/session_019aa9y32JcBuZ85KXe2jb8R

Adds .githooks/docstring-scan.sh. It asks the same question as CodeRabbit's
"Docstring Coverage" check: of the functions a change touches, how many
carry a docstring? It answers per function with added/modified provenance,
and in --check mode it blocks only on a newly-added undocumented function.
The Stop hook, the pre-commit validator and the CI backstop all consume it.

Tier 1 is shell. Every other source file reports as SKIPPED, never as
documented, and the SUMMARY line always prints its denominator.

scripts/tests/docstring-scan-test.sh (30 assertions) calibrates against
PR #1034 at 1cc72cd (2 files / 13 functions / 0.00% / 3 skipped). If
that commit is absent, the calibration fails rather than skipping. The
suite also covers:
- a planted positive and a negative control;
- added vs modified;
- predicate edges (trailing comment, shellcheck directive, heredoc body);
- --staged/--worktree parity;
- paths containing spaces or non-ASCII characters.

These mutants were each killed: a shellcheck directive counted as a
docstring, a heredoc body treated as code, untracked files dropped, a
trailing comment counted as a docstring, and a deleted fixture docstring.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aa9y32JcBuZ85KXe2jb8R
@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 54 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: e87b218f-ec6a-40c6-a9ed-aab8a3975c11

📥 Commits

Reviewing files that changed from the base of the PR and between bd9313a and c997ba9.

📒 Files selected for processing (2)
  • .githooks/docstring-scan.sh
  • scripts/tests/docstring-scan-test.sh

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@hyperpolymath
hyperpolymath enabled auto-merge (squash) September 30, 2026 10:19

This branch has not been deployed

No deployments
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.

1 participant