Skip to content

Configure layered Python linting - #102

Open
lodyai[bot] wants to merge 26 commits into
mainfrom
configure-df12-lints
Open

Configure layered Python linting#102
lodyai[bot] wants to merge 26 commits into
mainfrom
configure-df12-lints

Conversation

@lodyai

@lodyai lodyai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

This branch adopts layered Python linting so architectural, documentation and
snapshot defects are checked alongside Ruff. It pins df12-python-lints
v0.1.0, runs all twelve plug-in messages and ambrleaks under CPython 3.14,
and enables Ruff preview, ASYNC, DOC, and NumPy-style D rules.

The expanded policy also brings the existing Python tests, reviewed snapshots
and Rust test helpers into conformance without lint suppressions. Wrapped test
diagnostics are evaluated eagerly so the required assertion context does not
appear as uncovered, failure-only code to SlipCover.

Review walkthrough

Validation

  • make check-fmt: passed.
  • make lint: passed, including Ruff, 100% Interrogate coverage, focused PyPy
    Pylint, all df12 messages under CPython 3.14, ambrleaks, Rustdoc, Clippy and
    Whitaker.
  • make typecheck: passed.
  • make test: passed with 330 Rust tests, 10 Rust doctests, 197 Python tests
    and 16 reviewed snapshots.
  • CI-equivalent Python SlipCover: 93.81% line coverage, above the 92.07%
    ratchet baseline.
  • make markdownlint: passed, including spelling validation.
  • make nixie: passed.
  • mbake validate Makefile: passed.
  • git diff --check: passed.

References

Summary by Sourcery

Adopt layered Python linting and bring project tooling, tests, documentation, and boundary helpers into compliance with the expanded quality gates.

New Features:

  • Add layered Python linting with Interrogate, focused PyPy Pylint, pinned df12 Pylint checks, and ambrleaks snapshot scanning.
  • Add shared assertion diagnostics and reviewed snapshot contracts for Python tests and CI/build checks.

Bug Fixes:

  • Improve configuration validation for mapping keys, path values, and malformed diagnostic line indexes.
  • Harden extraction and bridge boundary handling while preserving public region and IR contracts.

Enhancements:

  • Expand Ruff policy to include asynchronous, documentation, and NumPy-style rules with a Python 3.14 baseline.
  • Expose clearer configuration-loading and parsing APIs and stabilize extraction state and test helper behavior.
  • Align Rust structural test helpers with the updated linting and diagnostic requirements.

Build:

  • Pin the df12 lint source, CPython 3.14 lint environment, and ty version in the Makefile and lockfile.

CI:

  • Validate layered lint ordering and tool configuration through Makefile and workflow contract tests.

Documentation:

  • Update the architecture decision record and developers' guide to document layered linting, assertion-helper usage, and maintenance boundaries.

Tests:

  • Update Python and Rust tests, snapshots, and property tests to satisfy the expanded lint and snapshot policy.

Chores:

  • Refresh documentation, type annotations, and lint-compliant test and helper code across the project.

@coderabbitai

coderabbitai Bot commented Jul 31, 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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: da2d3325-d9d3-4936-abcb-6f87416d0726

📥 Commits

Reviewing files that changed from the base of the PR and between 33eea7f and bebb90f.

📒 Files selected for processing (6)
  • docs/adr-004-python-linting-architecture.md
  • docs/contents.md
  • docs/developers-guide.md
  • docs/execplans/pr-102-layered-python-linting.md
  • python/stilyagi/config/parse.py
  • tests/test_config_schema.py
🔗 Linked repositories identified

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

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

Included review availability: 4 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


Summary

  • Add layered Python linting with Ruff, Interrogate, PyPy Pylint, df12-python-lints on CPython 3.14, and ambrleaks.
  • Pin df12-python-lints v0.1.0 and enable Ruff ASYNC, DOC, NumPy-style D, and pydoclint rules.
  • Document the linting architecture in ADR 004 and the developer guide.
  • Add the completed PR 102 ExecPlan.
  • Refine configuration APIs, validation, extraction helpers, and Python 3.14 typing.
  • Reject non-string configuration mapping keys and validate diagnostic line offsets.
  • Improve test diagnostics with assert_with_context.
  • Add snapshot coverage for Makefile targets, CI workflows, configuration, discovery, corpus shapes, and renderer output.
  • Update Rust and Python tests while preserving existing behaviour.

Validation

  • Pass formatting, linting, type checking, Rust and Python tests, snapshots, coverage, Markdown linting, Nixie, Makefile validation, and git diff --check.

Walkthrough

The pull request adds layered Python and Rust linting, updates typed Python configuration and extraction interfaces, improves diagnostic validation, and expands test assertions and snapshot coverage.

Changes

Repository quality updates

Layer / File(s) Summary
Layered lint workflow
Makefile, pyproject.toml, AGENTS.md, tests/test_makefile_recipes.py, tests/test_ci_workflow_units.py
The lint workflow adds Interrogate, df12 Pylint, and ambrleaks. It pins df12 configuration, uses Python 3.14, keeps Rust lint stages, and verifies command order and Whitaker wiring.
Python configuration and extraction contracts
python/stilyagi/config/*, python/stilyagi/engine/*, python/stilyagi/smoke.py, python/stilyagi/diagnostics_location.py
Configuration helpers become public. Mapping keys receive validation. Mutable defaults use named factories. Extraction state exposes public reset and warning helpers. Invalid line offsets fall back safely.
Test hardening and snapshots
tests/*, tests/__snapshots__/*, crates/stilyagi-markdown/src/tests/ir_consistency.rs
Tests use contextual assertions, shared Markdown fixtures, property checks, and snapshots. Existing expected outcomes remain unchanged.
Documentation and execution plan
docs/adr-004-python-linting-architecture.md, docs/developers-guide.md, docs/contents.md, docs/execplans/pr-102-layered-python-linting.md, docs/stilyagi-design.md
Documentation describes the layered lint workflow, typed configuration behaviour, extraction contracts, pinned tooling, and completed execution plan.

Suggested reviewers: leynos

Poem

Lint layers run in line,
Typed mappings now align.
Snapshots guard each route,
Context points failures out.
Rust checks share one plan,
Docs record what changed.

🚥 Pre-merge checks | ✅ 19 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Developer Documentation ⚠️ Warning ADR 004 was Accepted on the base, but the PR rewrites its title, decision tiers, consequences and operational notes before an addendum that only records lockfile alignment. Restore ADR 004's accepted text and record the layered-linting change in a dated addendum; keep the developer's guide and index aligned with that history.
✅ Passed checks (19 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the PR's main change: adopting layered Python linting.
Description check ✅ Passed The description clearly explains the layered linting changes, affected tooling, documentation, tests, and validation results.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
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 Pass the testing check: tests exercise config-key rejection, malformed line indexes, extraction cache and warnings, smoke validation, Makefile stage execution, and Rust diagnostic mutations with me...
User-Facing Documentation ✅ Passed The diff leaves docs/users-guide.md and supported package exports unchanged; it adds developer-only linting and internal validation/docs changes, documented in developers-guide.md and ADR 004.
Module-Level Documentation ✅ Passed Keep the check passing: all 78 Python modules have leading docstrings, all 88 Rust files have //! headers, and both added Python modules are documented.
Testing (Unit And Behavioural) ✅ Passed Pass the check: tests cover configuration edge and error paths, malformed line indexes, extraction invariants, smoke boundaries, CLI subprocess behaviour, and the hermetic make lint workflow.
Testing (Property / Proof) ✅ Passed Mark PASS: Hypothesis properties cover non-string mapping keys, malformed line indexes, monotonic offsets, and deterministic ordering; the diff introduces no proof assumption requiring exhaustive p...
Testing (Compile-Time / Ui) ✅ Passed No Rust or TypeScript compile-time behaviour changed; Rust changes are test-only. Changed CLI, CI, config, discovery and vocabulary contracts use focused stable snapshots with normalised paths and...
Unit Architecture ✅ Passed Pass: changed query paths remain read-only apart from existing isolated caches; new config I/O documents InvalidConfigError and the CLI catches it, while test-only state reset is explicit.
Domain Architecture ✅ Passed The aggregate diff changes no model or Rust production source; TOML/filesystem and Rust-bridge changes remain in config and extraction adapters, with engine/api retaining the public boundary.
Observability ✅ Passed The diff adds developer lint gates and local validation/adapter changes, not service or network behaviour; existing CLI and bridge warnings retain operation/path/index context, with logging tests c...
Security And Privacy ✅ Passed Accept the PR: the cumulative diff adds linting, validation, documentation, and tests; scans found no secrets or new unsafe execution/deserialization, and logging changes preserve existing diagnost...
Performance And Resource Use ✅ Passed The diff adds only linear line-index and mapping validation, preserves prior sequence materialisation, and improves config I/O reuse; vocabulary caching has zero arguments and no new unbounded hot-...
Concurrency And State ✅ Passed Accept: the diff adds no async or parallel execution; the existing process cache documents lock/reset ownership, and tests cover concurrent validation plus isolated resolver instances.
Architectural Complexity And Maintainability ✅ Passed Keep the change: assert_with_context has 253 uses across 25 test files, Rust helpers remove duplication, and changed production imports remain acyclic.
Rust Compiler Lint Integrity ✅ Passed The only Rust diff refactors Markdown consistency tests; all new helpers and imports are used, and it adds no lint suppressions or artificial anchors.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch configure-df12-lints

Warning

Your free Security trial is over. An organization admin can activate billing to continue.


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

@sourcery-ai

sourcery-ai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Reviewer's Guide

Configures layered Python linting by integrating df12-python-lints and ambrleaks into the Makefile and pyproject, tightens Ruff/Pylint policy for Python 3.14, and updates Python and Rust tests, helpers, and documentation to conform to the expanded lint and snapshot gates.

Sequence diagram for the layered make lint pipeline

sequenceDiagram
    actor Developer
    participant Makefile
    participant UV
    participant Ruff
    participant Interrogate
    participant PylintPyPy
    participant PylintDf12
    participant Ambrleaks
    participant CargoDoc
    participant CargoClippy
    participant Whitaker

    Developer->>Makefile: make lint

    Makefile->>UV: UV_RUN ruff check
    UV->>Ruff: ruff check

    Makefile->>UV: INTERROGATE interrogate
    UV->>Interrogate: interrogate --fail-under 100 python/stilyagi tests

    Makefile->>UV: PYLINT pylint-pypy --load-plugins=
    UV->>PylintPyPy: pylint-pypy python/stilyagi tests

    Makefile->>UV: DF12_PYLINT pylint --load-plugins=df12_python_lints
    UV->>PylintDf12: pylint --disable=all --enable=DF12_PYLINT_MESSAGES python/stilyagi tests

    Makefile->>UV: AMBRLEAKS ambrleaks
    UV->>Ambrleaks: ambrleaks tests

    Makefile->>CargoDoc: cargo doc
    Makefile->>CargoClippy: cargo clippy
    Makefile->>Whitaker: whitaker --all
Loading

File-Level Changes

Change Details Files
Integrate df12-python-lints and ambrleaks into the lint pipeline and Python tooling configuration.
  • Extend Makefile lint targets to run df12-backed Pylint under CPython 3.14 and ambrleaks over tests, with new DF12_* and AMBRLEAKS variables.
  • Pin df12-python-lints v0.1.0 in the dev dependency group in pyproject.toml and document the layered linting tiers, variables, and usage in ADR 004, developers-guide.md, AGENTS.md, and CI docs.
  • Update CI workflow tests to assert Python 3.14 usage, df12/Whitaker installation and Makefile-driven lint/test targets.
Makefile
pyproject.toml
docs/adr-004-python-linting-architecture.md
docs/developers-guide.md
AGENTS.md
tests/test_ci_workflow_units.py
Tighten Ruff, docstring, and type-checking policy to support layered linting and Python 3.14.
  • Enable Ruff ASYNC, D, and DOC rule families and configure flake8-type-checking runtime-evaluated decorators for Hypothesis/pytest-bdd.
  • Add pydoclint configuration to allow one-line docstrings but require explicit return/yield/raise sections for substantive docs.
  • Set Pylint py-version to 3.14 and adjust documentation to describe the stricter lint baseline and df12 suppression requirements.
pyproject.toml
docs/developers-guide.md
docs/adr-004-python-linting-architecture.md
Bring Python tests and snapshots into compliance with df12 assertion/suppression rules and snapshot contracts.
  • Add human-readable assertion messages throughout tests to satisfy explainability requirements and clarify expectations in failures.
  • Introduce syrupy SnapshotAssertion/JSONSnapshotExtension in multiple tests and move large structural expectations into reviewed JSON/ambr snapshots under tests/snapshots.
  • Adjust BDD and unit tests (check command, discovery, corpus, structural probe, CI workflow, Makefile recipes, IR adapters) to compare against snapshots rather than inline dicts or strings.
tests/test_package_skeleton_units.py
tests/test_config_schema.py
tests/test_build_spine_units.py
tests/test_config_resolution.py
tests/test_corpus.py
tests/test_structural_performance_probe.py
tests/test_check_command.py
tests/test_ci_workflow_units.py
tests/test_discovery.py
tests/test_round_trip_helpers.py
tests/test_rust_doc_comment_extraction.py
tests/test_python_docstring_extraction.py
tests/test_check_files.py
tests/test_diagnostics_location.py
tests/test_cli_e2e.py
tests/test_check_stdin.py
tests/test_package_structure_bdd.py
tests/test_renderers.py
tests/test_ir_error_adapter.py
tests/test_maturin_build_errors.py
tests/test_package_smoke.py
tests/test_discovery_properties.py
tests/test_config_schema_properties.py
tests/__snapshots__/test_build_spine_units/test_makefile_venv_target_declares_manifests_and_sync_recipe.json
tests/__snapshots__/test_check_command/test_check_pipeline_emits_stage_boundary_logs.json
tests/__snapshots__/test_check_command/test_main_renders_json_for_synthetic_diagnostics.json
tests/__snapshots__/test_ci_workflow_units.ambr
tests/__snapshots__/test_config_schema/test_baseline_config_parses_and_preserves_reserved_values.json
tests/__snapshots__/test_corpus/test_corpus_covers_required_source_shapes.json
tests/__snapshots__/test_discovery/test_directory_recursion_skips_noise_and_symlinked_directories.json
tests/__snapshots__/test_package_skeleton_units.ambr
Refine Python config, CLI, engine, and smoke helpers to improve type safety, documentation, and caching semantics.
  • Add explicit return-value sections to CLI and config helper docstrings and clarify error semantics in load/parse/validate modules.
  • Refactor config validation/coercion helpers (_ensure_extend_value, _coerce_path, _parse_cache_dir) to use structural pattern matching and stricter type checks.
  • Change smoke.ExtractDocument to a Python 3.12+ type alias and adjust related tests and helpers.
  • Simplify supported_region_kinds caching in engine.extraction by making the public function cached and resetting its cache in the test-only reset helper.
python/stilyagi/cli.py
python/stilyagi/config/validate.py
python/stilyagi/config/schema.py
python/stilyagi/config/load.py
python/stilyagi/config/parse.py
python/stilyagi/engine/extraction.py
python/stilyagi/engine/renderers.py
python/stilyagi/engine/checker.py
python/stilyagi/rules/registry.py
python/stilyagi/smoke.py
python/stilyagi/diagnostics_location.py
python/stilyagi/discovery.py
python/stilyagi/diagnostics.py
Adjust Rust IR and Markdown tests for new error handling, source-span validation, and proptest ergonomics.
  • Update markdown_ir_document helpers and malformed Markdown tests to return Result<IrDocument, Message>, threading Message errors instead of panicking.
  • Refactor segment and IR consistency tests to construct valid base documents via helpers, then mutate them per test, passing &IrDocument into assert_validation_reports.
  • Introduce static_regex_strategy for proptest regex-based strategies and adjust code/whitespace strategies in suppression tests to avoid expect panics and centralise pattern errors.
  • Tighten segment property tests to return Result from region_from_specs using fallible SourceSpan::new, mapping errors into proptest TestCaseError, and update callers accordingly.
  • Enhance coverage tests to pass explicit SourceSpan into frontmatter source-back validation in coverage.rs.
crates/stilyagi-markdown/src/tests/ir_consistency.rs
crates/stilyagi-markdown/src/tests/segment_validation.rs
crates/stilyagi-markdown/src/tests/coverage.rs
crates/stilyagi-markdown/src/tests/malformed.rs
crates/stilyagi-markdown/src/tests/suppression_support.rs
crates/stilyagi-ir/src/tests/suppression.rs
crates/stilyagi-ir/src/tests/segment_properties.rs

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.

@leynos

leynos commented Jul 31, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response. Ensure that this is validated against the current version of the codegraph.

If further refinement to address this finding would be deleterious, please supply a clear explanatory one to two paragraph markdown message I can paste into the CodeScene web ui's diagnostic suppression function so this diagnostic can be silenced.

crates/stilyagi-markdown/src/tests/ir_consistency.rs

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"]);

❌ 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

@leynos

leynos commented Jul 31, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response. Ensure that this is validated against the current version of the codegraph.

If further refinement to address this finding would be deleterious, please supply a clear explanatory one to two paragraph markdown message I can paste into the CodeScene web ui's diagnostic suppression function so this diagnostic can be silenced.

tests/test_config_resolution.py

Comment on lines +192 to +194

    assert resolved.cache_dir == pathlib.Path(".inline"), (
        "expected resolved.cache_dir == pathlib.Path('.inline')"
    )

❌ New issue: Code Duplication
The module contains 2 functions with similar structure: test_cli_overrides_win_over_every_config_source,test_explicit_config_path_and_inline_override_precedence

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '== Current revision =='
git rev-parse HEAD
git status --short

printf '%s\n' '== Module outline =='
ast-grep outline tests/test_config_resolution.py --items all --view expanded

printf '%s\n' '== Named tests and nearby context =='
rg -n -A80 -B20 \
  '^\s*def (test_cli_overrides_win_over_every_config_source|test_explicit_config_path_and_inline_override_precedence)\s*\(' \
  tests/test_config_resolution.py

printf '%s\n' '== Local fixtures/helpers =='
rg -n -A25 -B3 \
  '^\s*(def|class)\s+|^`@pytest`\.fixture' \
  tests/test_config_resolution.py

Length of output: 20419


@leynos tests/test_config_resolution.pytest_explicit_config_path_and_inline_override_precedence, test_cli_overrides_win_over_every_config_source

Do not refactor these tests. I validated the current codegraph at 7d2dd11e230a6d7362acb7c11b7ceae28779324b.

The tests have similar setup, but they verify different precedence boundaries. test_explicit_config_path_and_inline_override_precedence verifies that an inline --config fragment overrides a named explicit config file. test_cli_overrides_win_over_every_config_source verifies that a dedicated CLI option overrides discovered configuration, an explicit config file, and an inline fragment. Extracting or parametrizing this small sequence would obscure these separate contracts and make a failing assertion less diagnostic.

Paste this into the CodeScene diagnostic suppression field:

These tests intentionally repeat a small configuration setup. Each test documents and verifies a separate configuration-precedence boundary: inline --config content over a named explicit config file, and dedicated CLI overrides over every lower-precedence source.

A shared helper or parameterized test would hide the source ordering that each test must make explicit. The repeated setup is limited to test-local file creation and one resolution call. Keep the scenarios independent so failures identify the exact precedence contract that regressed.

You are interacting with an AI system.

@coderabbitai

This comment was marked as resolved.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@leynos

leynos commented Aug 2, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response. Ensure that this is validated against the current version of the codegraph.

If further refinement to address this finding would be deleterious, please supply a clear explanatory one to two paragraph markdown message I can paste into the CodeScene web ui's diagnostic suppression function so this diagnostic can be silenced.

crates/stilyagi-markdown/src/tests/ir_consistency.rs

Comment on file

fn validate_ir_consistency_reports_region_text_mismatches() {
    assert_validation_reports_on_first_region(
        |region| region.text.push_str(" drift"),
    assert_invalid_document(

❌ New issue: Code Duplication
The module contains 3 functions with similar structure: validate_ir_consistency_reports_invalid_origin_nodes,validate_ir_consistency_reports_region_text_mismatches,validate_ir_consistency_reports_unresolved_parent_regions

@coderabbitai

This comment was marked as resolved.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@leynos

leynos commented Aug 2, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response.

Large Method

tests/test_config_schema.py: test_baseline_config_parses_and_preserves_reserved_values

What lead to degradation?

test_baseline_config_parses_and_preserves_reserved_values has 78 lines, threshold = 70

Why does this problem occur?

Overly long functions make the code harder to read. The recommended maximum function length for the Python language is 70 lines of code. Severity: Brain Method - Complex Method - Long Method.

How to fix it?

We recommend to be careful here -- just splitting long functions don't necessarily make the code easier to read. Instead, look for natural chunks inside the functions that expresses a specific task or concern. Often, such concerns are indicated by a Code Comment followed by an if-statement. Use the EXTRACT FUNCTION refactoring to encapsulate that concern.

@coderabbitai

This comment was marked as resolved.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@leynos
leynos marked this pull request as ready for review August 17, 2026 00:00

@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, your pull request is larger than the review limit of 150000 diff characters

chatgpt-codex-connector[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

codescene-access[bot]

This comment was marked as outdated.

@leynos
leynos force-pushed the configure-df12-lints branch from 7356fb8 to e4a6f50 Compare August 17, 2026 00:26
codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@wafflecat-df12

Copy link
Copy Markdown
Collaborator

@coderabbitai review

leynos added 25 commits August 24, 2026 14:40
Evaluate wrapped assertion diagnostics through a shared test helper so
SlipCover measures executed test behaviour instead of failure-only message
expressions.

Keep inline assertions where pytest rewriting or type narrowing matters,
and document the test-only boundary for the helper.
Extract shared invalid-document setup and diagnostic assertions while
keeping each validation rule as a separately named test.

Preserve the setup panic message without `expect` so the Whitaker
test-helper policy remains green.
Separate public-field and reserved-value checks into focused helpers while
preserving the baseline configuration test's end-to-end setup and loading.
Enable the full thirteen-message v0.2.0 rule set under CPython 3.14
and pin the plugin and snapshot scanner to the same tag.

Add generated slots to the closed Makefile recipe case required by the
new dataclass-layout lint.
Resolve the lockfile from the rebased dependency set rather than carrying a
conflicted package graph from the feature branch.

Document the licence test helpers' return values and remove the unverified
exception claim so the enabled DOC checks describe their real contracts.
Assert the pinned df12 lint commands, messages, execution order, and
project configuration so `make lint` cannot silently lose a Python lint
layer. Clarify the `cache-dir` diagnostic to match the accepted path and
string inputs, with a regression test for invalid values.
Require both df12 Pylint and ambrleaks commands to use the shared
`DF12_PYTHON` selector, so the Makefile test protects their CPython 3.14
execution contract.
Record the resolved df12 Python lint dependency after preserving the target
branch's lockfile during the rebase conflicts.
Execute `make lint` through cmd-mox command doubles so the df12 Pylint
and ambrleaks stages cannot disappear or move behind the Rust linters.
Resolve df12 Pylint and ambrleaks from the same CPython 3.14 development
environment. Pin the package source to the immutable commit recorded in
`uv.lock` so a mutable Git tag cannot change the lint policy.
Validate normalised line starts before locating offsets so malformed IR
metadata consistently falls back to the first source location.
Return directly for truthy conditions while retaining the supplied diagnostic
when assertions fail.
Include the expected fragment in assertion failures to make parametrized
file-check regressions easier to diagnose.
Include the target and missing fragment in recipe-contract assertions to make
future failures immediately actionable.
Replace the previous Python type checker with strict Pyright and correct
the typed configuration and bridge boundaries it exposes.

Strengthen lint and location contracts, document the locked lint stack,
and keep malformed IR fixtures explicit.
Keep the linting guidance aligned with the immutable v0.2.0 source
revision, which includes the dataclass slots diagnostic.
Keep the hermetic Makefile stage-order contract intact while lowering
test complexity, and centralize line-index validity without changing
location fallback behaviour.
Run the documented type checker through the pinned ty 0.0.72
release so CI does not rely on an ambient executable. Restore the Python
3.14 ty configuration, update the contract test, and retain the
formatter-normalized developer guide.
Update the documented Whitaker invocation, layered linting reference, and
configuration and extraction boundaries to match the repository's current
Makefile and Python APIs.
Describe the public configuration boundaries, verify non-string mapping
keys directly and with Hypothesis, and preserve explicit successful cache
state transitions in extraction helpers.
Document the immutable df12 source, extraction vocabulary helpers, and the completed PR #102 linting work.
Reject non-string keys before parsing nested lint and Markdown mappings.
Add direct parser regressions so configuration callers receive a typed error
rather than key coercion or a comparison failure.
@leynos
leynos force-pushed the configure-df12-lints branch from bebb90f to de52d7e Compare August 24, 2026 13:09
codescene-access[bot]

This comment was marked as outdated.

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

@leynos

leynos commented Aug 25, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Have the following now been resolved?

python/stilyagi/engine/extraction.py (1)

67-85: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Finish each None helper with a bare return.
Add return after the successful state update, cache reset, and warning loop.

Do not use return None.
As per coding guidelines, “Add an explicit return at the end of functions (R503) - don't rely on implicit None returns.”
Also applies to: 88-100, 249-260

🤖 Detailed instructions

Use a wyvern agent team to verify each finding against the current code and only fix it if needed. Fix any documentation issues using a scribe agent team. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Use a scrutineer agent for execution of tests and summarizing the results.

In @python/stilyagi/engine/extraction.py around lines 67 - 85, Add a bare return
at the successful end of _validate_syntax_vocab_once after setting
_syntax_vocab_validated, and apply the same change to the other referenced
None-returning helpers after their state update, cache reset, or warning loop.
Do not use return None.

Source: Coding guidelines

@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

target='python/stilyagi/engine/extraction.py'

printf '%s\n' '== Current revision =='
git rev-parse HEAD
git status --short

printf '%s\n' '== Target helper bodies =='
rg -n -A42 -B4 \
  '^\s*def\s+(_validate_syntax_vocab_once|reset_extraction_state_for_tests|warn_unknown_ir_region_kinds)\s*\(' \
  "$target"

printf '%s\n' '== Bare returns in target =='
rg -n '^[[:space:]]+return[[:space:]]*$' "$target" || true

Length of output: 3685


@leynos File: python/stilyagi/engine/extraction.py
Symbols: _validate_syntax_vocab_once, reset_extraction_state_for_tests, warn_unknown_ir_region_kinds

Treat this finding as partially resolved at de52d7e4f1a6cb200e714a14c4e45922d42bd716.

_validate_syntax_vocab_once has the required bare return after the successful state update. reset_extraction_state_for_tests has the required bare return after the cache resets.

warn_unknown_ir_region_kinds still ends immediately after its warning loop. Add one bare return after the loop. Do not use return None.

  • Add the missing explicit bare return.
  • Run the configured formatter, linter, type checker, and focused extraction tests.

AI coding agent prompt:

Modify `python/stilyagi/engine/extraction.py` at the current revision.

Complete the remaining R503 explicit-return requirement.

The following functions already have the required bare returns. Do not modify them:

- `_validate_syntax_vocab_once`
- `reset_extraction_state_for_tests`

Update only `warn_unknown_ir_region_kinds`. Add a bare `return` immediately after its `for diagnostic in _unknown_ir_region_kinds(ir_payload):` warning loop.

Use:

```python
    return
```

Do not use `return None`.
Do not change the function signature, warning message, loop logic, imports, documentation, or other production behaviour.

Run the repository-configured formatter, linter, and type checker. Run focused extraction tests if they exist. Report the changed file and each command result.

  • 📌 Create a pull request with these changes

You are interacting with an AI system.

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.

4 participants