Skip to content

Document docstrings and repair test helpers - #96

Draft
leynos wants to merge 2 commits into
mainfrom
docstring-guidance
Draft

Document docstrings and repair test helpers#96
leynos wants to merge 2 commits into
mainfrom
docstring-guidance

Conversation

@leynos

@leynos leynos commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

This draft records the canonical Python docstring conventions in AGENTS.md.

Its first CI run exposed four still-valid Whitaker no_expect_outside_tests findings in Rust test-support functions. The separate conformance commit propagates fixture-construction errors, moves test-verdict unwrapping into recognised test bodies, keeps shared assertion helpers query-only, and uses one documented structural construction boundary per affected proptest crate. It adds no lint suppressions, exclusions, or naming workarounds.

Because that repair spans seven Rust test files, this PR is intentionally left as a draft for review rather than auto-merged.

Validation

  • Focused stilyagi-ir: rustfmt, Clippy, 57 tests, two doctests, Whitaker
  • Focused stilyagi-markdown: rustfmt, Clippy, 81 tests, Whitaker
  • Full make all:
    • make check-fmt
    • make typecheck
    • make lint, including full-workspace Whitaker
    • make test — 330 Rust tests, 10 doctests, 195 Python tests
    • make markdownlint — including 12 spelling-policy tests
    • make nixie
  • Confirmed the remote branch matches 08cfa3d68ae407acc01006f27bc0261135b43ef4
  • Confirmed the worktree is clean

References

Define comprehensive NumPy-style documentation for public APIs and concise,
selective documentation for private helpers and tests.

@sourcery-ai sourcery-ai 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.

Sorry @leynos, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@leynos
leynos enabled auto-merge (squash) July 29, 2026 12:03
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Update contributor documentation and refactor IR and Markdown tests to propagate construction errors, centralise static regex strategies, and validate explicitly mutated documents and source spans.

Changes

Test quality updates

Layer / File(s) Summary
Documentation guidance
AGENTS.md
Add NumPy-style documentation requirements for public APIs and concise guidance for private helpers and tests.
Fallible test construction
crates/stilyagi-ir/src/tests/segment_properties.rs, crates/stilyagi-markdown/src/tests/malformed.rs
Propagate region and document construction errors, with explicit handling at test call sites.
Shared test strategies
crates/stilyagi-ir/src/tests/suppression.rs, crates/stilyagi-markdown/src/tests/suppression_support.rs
Centralise static regex strategy construction behind descriptive panic boundaries.
Markdown validation test harnesses
crates/stilyagi-markdown/src/tests/coverage.rs, crates/stilyagi-markdown/src/tests/ir_consistency.rs, crates/stilyagi-markdown/src/tests/segment_validation.rs
Pass source spans and already-mutated documents directly into validation helpers using shared canonical test setup.

Possibly related PRs

Poem

Spans now speak when builders fail,
Regex helpers share one trail.
Documents mutate, then tests report,
Clearer guidance strengthens the court.
Small helpers keep their tales concise.

🚥 Pre-merge checks | ✅ 20
✅ Passed checks (20 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Testing (Overall) ✅ Passed Approve: the new tests mutate real IR/doc state and assert concrete diagnostics, round-trips, and invariants; no vacuous mock-only checks found.
User-Facing Documentation ✅ Passed The patch only changes AGENTS.md contributor guidance and internal test helpers; no production or user-facing docs changed, so docs/users-guide.md is not needed.
Developer Documentation ✅ Passed Only AGENTS.md and test-only helpers changed; no developer-guide, design doc, ADR, roadmap, or execplan updates were needed.
Module-Level Documentation ✅ Passed Each touched Rust module has a //! docstring stating its test/helper purpose; the nested suppression_proptest.rs also does.
Testing (Unit And Behavioural) ✅ Passed Tests exercise public Markdown/IR APIs and cover edge cases and error paths, including malformed fixtures, invalid spans, and consistency violations.
Testing (Property / Proof) ✅ Passed No new invariant or lemma is introduced; the change only refactors test scaffolding and doc guidance, with existing property coverage already in place.
Testing (Compile-Time / Ui) ✅ Passed PASS: Touch only test helpers and AGENTS.md; no new compile-time surface or UI/text output needing trybuild/snapshot coverage is introduced.
Unit Architecture ✅ Passed PASS: fallible fixture construction is now explicit at test boundaries, and validation helpers take pre-mutated documents, keeping query paths read-only.
Domain Architecture ✅ Passed Only AGENTS.md and test files changed; no domain, adapter, transport, persistence, or infrastructure code was altered.
Observability ✅ Passed Review the commit scope: it changes AGENTS.md and test-only helpers, with no production code, runtime behaviour, logging, metrics, tracing, or alerts to assess.
Security And Privacy ✅ Passed Only doc/test changes; no secrets, auth/permission, or unsafe sinks added, and all new panic/error text stays generic.
Performance And Resource Use ✅ Passed Only test/doc changes landed; no new hot-path loops, unbounded growth, or repeated I/O were introduced.
Concurrency And State ✅ Passed No shared mutable state, async work, locks, or ordering-sensitive logic was introduced; the changes are local test-fixture refactors and doc guidance.
Architectural Complexity And Maintainability ✅ Passed PASS: changes are docs and local test helpers only; they reduce boilerplate without adding new layers, traits, registries, or hidden orchestration.
Rust Compiler Lint Integrity ✅ Passed Approve: no #[allow]/#[expect] or fake anchors were added, helper modules are used by sibling tests, and the clones duplicate fixtures intentionally.
Title check ✅ Passed It summarises both the new docstring guidance and the test-helper refactors in the changeset.
Description check ✅ Passed It describes the docstring guidance and the Rust test-helper fixes in the PR.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docstring-guidance

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

@sourcery-ai

sourcery-ai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds explicit Python docstring conventions for public APIs and private helpers to AGENTS.md, emphasizing NumPy-style docstrings, CQRS/cohesion review for verbose helpers, and meaningful test documentation.

Flow diagram for private helper docstring conventions

flowchart TD
  A["Write or update private helper"] --> B["Add single-line docstring by default"]
  B --> C{"Need explanatory paragraph?"}
  C -- "No" --> D["Keep concise single-line docstring"]
  C -- "Yes" --> E["Review for CQRS and cohesion issues"]
  E --> F{"Responsibilities conflated?"}
  F -- "Yes" --> G["Split or extract focused helper"]
  G --> B
  F -- "No" --> H["Responsibility cohesive; explanation documents local constraint"]
  H --> I["Keep paragraph and optional NumPy-style sections"]
Loading

File-Level Changes

Change Details Files
Define Python docstring standards for public APIs, private helpers, and tests in the agent documentation.
  • Require comprehensive NumPy-style docstrings with examples for public functions, classes, and methods.
  • Encourage concise single-line docstrings for private helpers and prescribe CQRS/cohesion review when longer explanations are needed.
  • Allow structured NumPy-style sections for private helpers only when describing non-obvious behaviour.
  • Clarify that test documentation should avoid examples that merely restate test logic.
AGENTS.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

codescene-access[bot]

This comment was marked as outdated.

Return fixture construction failures to recognized test bodies and keep
shared assertion helpers query-only.

Centralize static proptest regex literals behind documented test-definition
boundaries so Whitaker sees no anonymous expects outside tests.

@codescene-access codescene-access 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.

Gates Failed
Enforce advisory code health rules (1 file with Code Duplication)

Our agent can fix these. Install it.

Gates Passed
5 Quality Gates Passed

Reason for failure
Enforce advisory code health rules Violations Code Health Impact
ir_consistency.rs 1 advisory rule 10.00 → 9.39 Suppress

See analysis details in CodeScene

Quality Gate Profile: Pay Down Tech Debt
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

Comment on lines +127 to +132
let mut document = valid_document().expect("expected Markdown IR document");
if let Some(node) = document.nodes.first().cloned() {
document.nodes.push(node);
}

assert_validation_reports(&document, "ir-duplicate-node-id", &["duplicate node id"]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

❌ New issue: Code Duplication
The module contains 5 functions with similar structure: validate_ir_consistency_reports_duplicate_node_ids,validate_ir_consistency_reports_duplicate_region_ids,validate_ir_consistency_reports_invalid_origin_nodes,validate_ir_consistency_reports_region_text_mismatches and 1 more functions

Suppress

@leynos
leynos marked this pull request as draft July 29, 2026 12:27
auto-merge was automatically disabled July 29, 2026 12:27

Pull request was converted to draft

@leynos leynos changed the title Document Python docstring conventions Document docstrings and repair test helpers Jul 29, 2026

@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

🤖 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 `@AGENTS.md`:
- Around line 26-28: Update the public API documentation rule in AGENTS.md to
align its example requirement with the rule at lines 23–25 by either requiring
examples for every public API or defining explicit exceptions for “where
appropriate.” Remove the duplicated test-documentation rule at lines 43–44, or
designate one occurrence as canonical.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 64e145da-358c-4613-a836-4fe3249a9e5b

📥 Commits

Reviewing files that changed from the base of the PR and between 6383c93 and 08cfa3d.

📒 Files selected for processing (8)
  • AGENTS.md
  • crates/stilyagi-ir/src/tests/segment_properties.rs
  • crates/stilyagi-ir/src/tests/suppression.rs
  • crates/stilyagi-markdown/src/tests/coverage.rs
  • crates/stilyagi-markdown/src/tests/ir_consistency.rs
  • crates/stilyagi-markdown/src/tests/malformed.rs
  • crates/stilyagi-markdown/src/tests/segment_validation.rs
  • crates/stilyagi-markdown/src/tests/suppression_support.rs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • leynos/pylint-pypy-shim (auto-detected)
  • leynos/episodic (auto-detected)

Comment thread AGENTS.md
Comment on lines +26 to +28
- **Document public APIs comprehensively.** Public functions, classes, and
methods must have comprehensive NumPy-style docstrings, including clear
examples that demonstrate usage and outcome where appropriate.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Reconcile the overlapping documentation rules.

Make the example requirement consistent with lines 23–25: require examples for every public API, or define explicit exceptions for “where appropriate”. Remove the repeated test-documentation rule at lines 43–44, or make one rule canonical.

Triage: [type:docstyle]

As per coding guidelines, documentation guidance must remain clear, concise, and maintainable.

Also applies to: 43-44

🤖 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 `@AGENTS.md` around lines 26 - 28, Update the public API documentation rule in
AGENTS.md to align its example requirement with the rule at lines 23–25 by
either requiring examples for every public API or defining explicit exceptions
for “where appropriate.” Remove the duplicated test-documentation rule at lines
43–44, or designate one occurrence as canonical.

Source: Coding guidelines

@codescene-access codescene-access 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.

No quality gates enabled for this code.

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