Skip to content

Add harness documentation check - #50

Open
puneetdixit200 wants to merge 4 commits into
markmishaev76:mainfrom
puneetdixit200:codex/harness-docs-check
Open

Add harness documentation check#50
puneetdixit200 wants to merge 4 commits into
markmishaev76:mainfrom
puneetdixit200:codex/harness-docs-check

Conversation

@puneetdixit200

@puneetdixit200 puneetdixit200 commented May 20, 2026

Copy link
Copy Markdown

What does this PR do?

Adds the documentation.harness_docs check proposed in #33. The check awards full credit when CONTRIBUTING/docs describe CI stages, quality gates, pre-commit, development workflow, or how to add a quality check; partial credit is available for a CONTRIBUTING.md without pipeline detail or CI comments documenting checks.

Closes #33.

Type of change

  • New check
  • Bug fix
  • Refactor
  • Documentation
  • CI/tooling

Checklist

  • Tests added/updated (pass + fail cases for new checks)
  • ruff check and ruff format pass
  • mypy src/ passes
  • Self-assessment score does not regress (31/32 checks pass, grade A 92.0/100)
  • ARCHITECTURE.md updated if module structure changed (not applicable)

Testing

  • .venv/bin/python -m pytest tests/test_checks.py -q -k harness_docs
  • .venv/bin/python -m pytest tests/test_checks.py -q
  • .venv/bin/python -m pytest -q
  • .venv/bin/ruff check src/ tests/
  • .venv/bin/ruff format --check src/ tests/
  • .venv/bin/mypy src/
  • .venv/bin/bandit -r src/ -c pyproject.toml
  • .venv/bin/pip-audit
  • .venv/bin/ai-harness-scorecard assess .
  • git diff --check

AI Usage

This PR was prepared with AI assistance. I reviewed the implementation and validated it with the commands listed above.

Summary by CodeRabbit

  • New Features

    • Added a check that verifies project documentation includes quality-pipeline information (CI/workflow, quality gates, contribution guidance).
  • Documentation

    • Updated total check count (31 → 32) and adjusted example output wording to reflect the new count.
  • Tests

    • Added unit and property-based tests covering pass/partial/fail outcomes for the new documentation check.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@puneetdixit200 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 40 minutes and 21 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 07042a0a-1b60-4649-bcad-133177312ca7

📥 Commits

Reviewing files that changed from the base of the PR and between 4349b75 and 2283743.

📒 Files selected for processing (1)
  • tests/test_checks.py
📝 Walkthrough

Walkthrough

Adds a new documentation check, HarnessDocsCheck, that detects documented CI/quality-pipeline guidance (pass/partial/fail), registers it, adds tests (including Hypothesis variants), and updates the README counts to 32 checks.

Changes

Quality Pipeline Documentation Check

Layer / File(s) Summary
HarnessDocsCheck implementation and registration
src/ai_harness_scorecard/checks/documentation.py
Adds re import and defines HarnessDocsCheck with regex patterns and run() logic to detect pipeline/quality-gate/workflow documentation; registers HarnessDocsCheck() in DOCUMENTATION_CHECKS.
README updates
README.md
Updates “What It Checks” total to 32 and the example output fraction for “Architectural Docs” to match the new total.
HarnessDocsCheck test suite
tests/test_checks.py
Adds TestHarnessDocsCheck covering pass (docs/development.md), partial (CONTRIBUTING.md only), and fail cases, plus a Hypothesis-driven property test; updates test imports for TemporaryDirectory and Hypothesis utilities.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • markmishaev76

Poem

🐰 I sniffed the docs and found the trail,
CI stages written without fail,
A harness check hops in at thirty-two,
Guiding gates for contributors new,
Hooray — the pipeline's tale is true!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The implementation adds HarnessDocsCheck with detection logic for CI pipeline documentation (patterns, partial/fail cases), tests covering pass/partial/fail scenarios, and README updates reflecting the new check count.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the harness documentation check: new check class, comprehensive test suite, and README updates to reflect the additional check.
Title check ✅ Passed The title 'Add harness documentation check' clearly and directly summarizes the main change: implementing a new documentation check that validates CI pipeline documentation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@puneetdixit200
puneetdixit200 marked this pull request as ready for review May 20, 2026 07:01

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/test_checks.py (1)

293-331: ⚡ Quick win

Add a Hypothesis test for regex-variant pipeline wording.

Given this check is regex-driven, add at least one property-based test that fuzzes casing/spacing/keyword variants to harden detection behavior beyond these three fixed fixtures.

As per coding guidelines tests/test_*.py: Use property-based tests with hypothesis for fuzz-like input generation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_checks.py` around lines 293 - 331, The tests lack a property-based
Hypothesis test to fuzz regex variants for the harness pipeline wording; add a
new test in tests/test_checks.py that uses Hypothesis strategies (e.g., text(),
sampled_from(), one_of(), and regex-generated variants) to generate
casing/spacing/keyword variants of phrases like "CI pipeline", "quality
pipeline", "ci-pipeline", etc., build the repo context via _build_context with
the generated doc content, run HarnessDocsCheck().run(context), and assert that
expected detection occurs (passed/full score for strong matches, at least
partial pass for contributing-only variants); reference HarnessDocsCheck and
_build_context so the test exercises the same detection logic used by existing
tests and follows the project's test style.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@README.md`:
- Around line 32-35: The example score table in README.md is inconsistent: the
"Architectural Documentation" category lists 6 checks but the example row shows
"3/5"; update that example row to use the correct denominator "3/6". Locate the
example score table row for "Architectural Documentation" in README.md and
change the displayed score from "3/5" to "3/6" so it matches the listed check
count.

---

Nitpick comments:
In `@tests/test_checks.py`:
- Around line 293-331: The tests lack a property-based Hypothesis test to fuzz
regex variants for the harness pipeline wording; add a new test in
tests/test_checks.py that uses Hypothesis strategies (e.g., text(),
sampled_from(), one_of(), and regex-generated variants) to generate
casing/spacing/keyword variants of phrases like "CI pipeline", "quality
pipeline", "ci-pipeline", etc., build the repo context via _build_context with
the generated doc content, run HarnessDocsCheck().run(context), and assert that
expected detection occurs (passed/full score for strong matches, at least
partial pass for contributing-only variants); reference HarnessDocsCheck and
_build_context so the test exercises the same detection logic used by existing
tests and follows the project's test style.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9baed599-6a73-4541-a93f-4fba484cb883

📥 Commits

Reviewing files that changed from the base of the PR and between 5536e96 and 9d7b5d2.

📒 Files selected for processing (3)
  • README.md
  • src/ai_harness_scorecard/checks/documentation.py
  • tests/test_checks.py

Comment thread README.md

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/test_checks.py (1)

294-295: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Align new test names with the required pass/fail naming convention.

The new methods should follow test_<check_id>_pass / test_<check_id>_fail for consistency and discoverability.

As per coding guidelines, "Name test functions as test_<check_id>_pass or test_<check_id>_fail".

Also applies to: 314-315, 323-324, 346-347

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_checks.py` around lines 294 - 295, The test function names don't
follow the required test_<check_id>_pass/fail convention; rename the new tests
in tests/test_checks.py so they match that pattern (e.g., change
test_harness_docs_pass_with_ci_pipeline_docs to test_harness_docs_pass) and
likewise rename the other three newly added tests to
test_<appropriate_check_id>_pass or test_<appropriate_check_id>_fail as
applicable, and update any references/imports or pytest markers that use the old
names (look for the HarnessDocsCheck-related tests and the three other new tests
mentioned in the review).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/test_checks.py`:
- Around line 358-361: The test is using TemporaryDirectory directly; change it
to use the pytest tmp_path fixture instead by adding tmp_path to the test
function signature and replacing the TemporaryDirectory() block with a Path from
tmp_path (e.g., tmp_path / "repo" or similar) passed into _build_context; update
any uses of Path(tmp_dir) to use that tmp_path-derived Path and remove the
TemporaryDirectory import/usage. Target symbols: the test function that calls
_build_context and the _build_context call itself.

---

Outside diff comments:
In `@tests/test_checks.py`:
- Around line 294-295: The test function names don't follow the required
test_<check_id>_pass/fail convention; rename the new tests in
tests/test_checks.py so they match that pattern (e.g., change
test_harness_docs_pass_with_ci_pipeline_docs to test_harness_docs_pass) and
likewise rename the other three newly added tests to
test_<appropriate_check_id>_pass or test_<appropriate_check_id>_fail as
applicable, and update any references/imports or pytest markers that use the old
names (look for the HarnessDocsCheck-related tests and the three other new tests
mentioned in the review).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b5a5f069-e01a-46b6-a446-b25fa015b926

📥 Commits

Reviewing files that changed from the base of the PR and between 9d7b5d2 and 4349b75.

📒 Files selected for processing (2)
  • README.md
  • tests/test_checks.py
✅ Files skipped from review due to trivial changes (1)
  • README.md

Comment thread tests/test_checks.py Outdated
@puneetdixit200 puneetdixit200 changed the title [codex] Add harness documentation check Add harness documentation check May 20, 2026

@markmishaev76 markmishaev76 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for this, and sorry it sat so long. The check is a good idea and the implementation is clean. Reviewed it locally on the PR head; one substantive concern about how loosely it credits, plus a couple of smaller notes.

Verified locally, because the CI workflows never ran on this PR (only CodeRabbit and GitGuardian reported, since Actions needs maintainer approval for a first-time contributor). On the PR head: 112 tests pass, ruff check and ruff format --check clean, mypy --strict clean across 18 source files. The branch is also up to date with main, so no rebase needed. I will approve the workflow run so the real suite reports too.

The category-scoring interaction is correct: CategoryScore.max_points sums max_points dynamically and the 20% weight comes from CATEGORY_CONFIG, so Architectural Docs going from 20 to 22 points dilutes within the category without touching cross-category weighting. The README table update to 3/6 is right.


Main concern: the fallback branches credit almost any repository

The check has three ways to score, and the lower two are loose enough that most repos will get points without documenting anything. Probed against the branch:

repository content score evidence
docs/setup.md containing only "We use pre-commit locally, optional." 2.0/2.0 Quality pipeline documented in docs/setup.md
CI file whose only comment is # run the test suite 1.0/2.0 CI config comments mention quality checks
CI file whose only comment is # workflow owner: platform 1.0/2.0 CI config comments mention quality checks
CONTRIBUTING.md containing only # Contributing 1.0/2.0 Found CONTRIBUTING.md, but no documented quality pipeline

Two specific causes:

  1. \bpre-commit\b sits in PIPELINE_PATTERNS alongside genuinely strong signals like how\s+to\s+add\s+(a\s+)?(new\s+)?(check|quality\s+gate|ci\s+job). A passing mention of the word earns full marks, which is a much weaker signal than the others in that list.

  2. COMMENTED_CI_PATTERN matches ^\s*#.*\b(ci|quality|check|lint|test|type|gate|workflow)\b against ci_raw_content(). With ci, test, type and workflow in that alternation, virtually every CI file in existence has a comment that matches, including the word workflow appearing in an unrelated comment. That is close to free half credit.

This matters more than usual for this project because the whole value of the scorecard is discriminating between repos that have the safeguard and repos that do not. A check that awards ≥1.0/2.0 almost universally adds points without adding signal. Suggestions: drop bare pre-commit from the full-credit list, or demote it to the partial tier; and tighten the CI-comment alternation to multi-word phrases (quality gate, ci stage, pre-commit hook) rather than single common words.

Related: DOCUMENTATION_FILES uses docs/*.md, and because has_file/search_any_file use fnmatch on the full relative path, * also matches /. So docs/*.md recursively matches docs/adr/0002-additive-scoring-model.md and deeper. That is probably what you want, but it widens the false-positive surface for the loose patterns above, so it is worth being deliberate about.

Smaller notes

No test covers the COMMENTED_CI_PATTERN branch. The tests cover the full-credit path, the CONTRIBUTING.md partial path, the fail path, and the pattern variants, but nothing constructs a repo with only a CI config. That is the loosest branch in the check, so it is the one most worth pinning down.

check_id naming. documentation.harness_docs follows AGENTS.md, but all 31 existing checks use bare snake_case (architecture_doc, agent_instructions, adr_presence). Since check_id is emitted by the JSON reporter, this introduces one dotted ID into otherwise-flat output. The dotted form is the documented one so I would rather keep it and migrate the others separately, but flagging it so it is a deliberate choice. #52 makes the same call with testing.code_duplication.

Test import style. The tests import HarnessDocsCheck inside each test function. Everything else in tests/test_checks.py imports at module level; worth matching.

Merge coordination

#52 also adds a check and also rewrites the README from "31 checks" to "32 checks". Whichever merges second needs to say 33 and keep both category rows updated.

Happy to merge once the credit thresholds are tightened, or to take that on myself in a follow-up if you would rather land the check as-is; let me know which you prefer.

@markmishaev76

Copy link
Copy Markdown
Owner

Closing and immediately reopening to trigger the CI workflows, which never ran on this PR (fork PR, zero recorded runs). Not a rejection.

@markmishaev76

Copy link
Copy Markdown
Owner

CI is now green on all 9 checks (lint, typecheck, test, security, audit, docs, self-assess, plus CodeRabbit and GitGuardian), which matches what I saw locally. The review feedback above is the only thing outstanding.

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.

New check: harness documentation (documented quality pipeline)

2 participants