Skip to content

Adopt the Polonius-enabled nightly and retire the -Z directive - #577

Merged
leynos merged 16 commits into
mainfrom
use-polonius-enabled-nightly
Aug 28, 2026
Merged

leynos merged 16 commits into
mainfrom
use-polonius-enabled-nightly

Conversation

@leynos

@leynos leynos commented Aug 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

This branch moves the pinned Rust toolchain from nightly-2026-06-25 to
nightly-2026-08-13 and removes every instruction that passed a
-Zpolonius directive to Cargo. Nightlies dated 2026-08-04 and later run the
Polonius alpha analysis by default, so the dated pin now carries the
borrow-checker requirement on its own and the directive is redundant.

The plumbing is removed wholesale rather than left inert. The directive is
being retired upstream, and a build that restates it is a build that can
silently drop it — the failure mode the old contract test existed to catch.
ADR-006's decision is unchanged; only the mechanism that implements it is.

Review walkthrough

Start with the two files that define the new policy:

Then the inverted contract, which is the safeguard against regression:

  • tests/polonius_toolchain_contract.rs
    — the test no longer asserts the flag is present everywhere. It now
    requires the pinned channel to be a dated nightly at or after 2026-08-04,
    and fails if any build-configuration surface reintroduces a -Zpolonius
    directive.

Then the removals themselves, which are mechanical:

  • .cargo/config.toml is deleted; carrying the flag was its only purpose.
  • Makefile
    — POLONIUS_FLAGS is gone. kani-full and the binary-build recipe now set
    no RUSTFLAGS at all, so only the lint gates set it, and only to deny
    warnings.
  • tools/dev-fast/config.toml,
    and the four workflows' with.rustflags inputs.
  • docs/developers-guide.md
    — the rewritten "Toolchain and borrow checker" section, and the
    shared-action contract
    below it.

Finish with the fallout the newer toolchain surfaced, which is the least
obvious part of the branch. Cargo 1.99 no longer creates target/debug/deps/:
it runs integration tests from <profile>/build/<pkg>/<hash>/out/ and gives
every crate its own directory.

  • test_support/src/netsuke/locator.rs
    — profile_dir derives the profile directory from either executable
    layout. This module is new only in the sense that it was split out of
    test_support/src/netsuke.rs, which had grown past the module line cap.
  • tests/locale_stub_ui_tests.rs
    and
    tests/command_env_ui_tests.rs
    — both UI-fixture harnesses now collect the parent directory of every
    loadable artefact Cargo reports. Note that this must accept proc-macro
    dynamic libraries as well as rlibs: a shared deps/ directory used to pick
    proc macros up as a side effect, so an rlib-only filter went unnoticed
    until each crate got its own directory, at which point dependents failed
    with E0463.

Two clippy lints new to this nightly are fixed at the source rather than
suppressed: assert_is_empty in
tests/ir_tests.rs,
src/graph_view/tests.rs
and
src/status_timing_tests.rs,
and chunks_exact_to_as_chunks in
src/hex_property_tests.rs.

Validation

All four gates run on the bumped toolchain, sequentially, from a clean tree:

make check-fmt   pass
make lint        pass  (rustdoc, clippy, and both Whitaker Dylint passes)
make test        pass  (2279/2279 nextest tests, 3 skipped; all doctests)
make markdownlint pass (85 files, 0 errors)

The Polonius default was verified empirically rather than taken from the
compiler's -Z help text, which still reports default: no. The classic
NLL problem case #3 — a conditional early return of a borrow from a map —
compiles with no flag on nightly-2026-08-13 and is rejected on
nightly-2026-06-25.

Notes

  • Kani borrow-checks under NLL. Kani manages its own supporting nightly,
    which for 0.67.0 is nightly-2025-11-21 — earlier than the Polonius
    default. Under the retired flag, make kani-full passed -Zpolonius=next
    through RUSTFLAGS and so got the analysis; it no longer does. This is
    harmless today because the tree has no POLONIUS(...)-tagged sites, but it
    is a real gap. Both
    docs/polonius.md
    and the developers' guide record it, and say to move Kani forward rather
    than reinstate the directive.
  • -Zpolonius=legacy is not an NLL fallback. It was checked: it accepts
    the same programs as the default. Classifying a new borrow-centric API
    against NLL now means compiling it on a pre-2026-08-04 nightly, which
    docs/polonius.md
    states.
  • CHANGELOG.md is unchanged. The repository follows Common Changelog
    and keeps no Unreleased section; the existing Polonius entry sits under
    the released 0.1.0-beta1 heading and describes what that release did.
    Recording this change is left to the next release cut, when the version
    heading exists.
  • The RUSTFLAGS contract model was simplified. Every recipe that still
    sets RUSTFLAGS does so for one reason — to deny warnings while
    conditionally preserving an inherited value — so the per-case
    WarningPolicy and InheritancePolicy fields had no remaining variants
    and were removed. A recipe needing a different policy will fail the
    assertions rather than pass silently, which is the signal to reintroduce
    them.

Summary by Sourcery

Adopt the newer Polonius-enabled nightly as the sole compiler-policy mechanism and remove the retired explicit directive from build configuration, CI, documentation, and tests.

Bug Fixes:

  • Update test harnesses to support Cargo 1.99’s split per-crate artifact directories and proc-macro metadata discovery.
  • Resolve binary locations across both legacy and newer Cargo integration-test layouts.

Enhancements:

  • Adopt a dated nightly with Polonius and the next-generation trait solver enabled by default, removing all explicit Polonius flag plumbing.
  • Simplify Makefile, development, CI, and workflow contracts so RUSTFLAGS is used only for warning enforcement where needed.
  • Refresh documentation and architectural guidance to describe the toolchain pin as the single source of compiler behavior.
  • Address new nightly Clippy lints in tests and production test-support code.

CI:

  • Update CI and packaging workflows to the newer pinned nightly and remove redundant Polonius rustflags.

Documentation:

  • Revise installation, developer, ADR, and Polonius migration documentation for the default-enabled analysis and updated nightly pin.

Tests:

  • Invert the toolchain contract tests to enforce a sufficiently recent nightly and reject reintroduced -Zpolonius directives.
  • Update Makefile and workflow contract tests for the simplified flags policy and add coverage for new Cargo artifact layouts.

Chores:

  • Split binary-location helpers into a dedicated module to preserve maintainability limits.

References

@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Warning

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

@coderabbitai

coderabbitai Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

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

Summary

  • Update the pinned Rust nightly to nightly-2026-08-23, which enables Polonius by default.
  • Remove explicit -Zpolonius=next configuration from Cargo, Make, CI, tooling, documentation, and contract tests.
  • Require dated nightlies from 2026-08-04 onwards and reject reintroduced Polonius directives.
  • Support Cargo’s split artifact directories and Windows command-line limits with shared artefact discovery and UTF-8 rustc response files.
  • Refactor Netsuke test support for executable discovery and process execution.
  • Refactor Rustdoc coverage into doc_coverage_model.py and doc_coverage_runner.py, with immutable models, clearer validation, and focused tests.
  • Document Kani 0.67.0’s bundled nightly-2025-11-21 NLL toolchain as a separate exception in ADR-006.
  • Add the Rustdoc coverage debugging plan in docs/debugging/debugging-plan-20260825-doc-coverage.md.

Walkthrough

The repository now uses nightly-2026-08-23 for default Polonius support. Explicit Polonius flags were removed from build paths, workflows, Makefile recipes, installation guidance, and contract tests. Coverage, UI harness, and Netsuke test-support code was reorganized.

Changes

Polonius nightly migration

Layer / File(s) Summary
Toolchain and build configuration
.cargo/config.toml, .github/workflows/*, Makefile, rust-toolchain.toml, tools/dev-fast/config.toml
Build and CI paths use the pinned nightly and no longer pass -Zpolonius=next.
Toolchain contracts and guidance
AGENTS.md, README.md, docs/*, tests/*polonius*, tests/documentation_installation_tests.rs
Guidance and contract tests require the dated nightly and reject retired Polonius directives.
Rustdoc coverage file collection
scripts/doc-coverage.py, scripts/doc_coverage_model.py, scripts/doc_coverage_runner.py, scripts/tests/test_doc_coverage.py, docs/debugging/*
Coverage models and execution moved into dedicated modules. Rustdoc coverage is read from generated JSON files.
UI harness artefact discovery and compilation
tests/command_env_ui_tests.rs, tests/locale_stub_ui_tests.rs, tests/support/cargo_artifacts.rs, tests/support/rustc_response_file.rs
Direct rustc harnesses discover Cargo artefacts across layouts and pass arguments through response files.
Netsuke test-support execution and location
test_support/src/netsuke/*, docs/developers-guide.md
Executable lookup supports Cargo build-output layouts. Process execution uses isolated environment helpers.
Supporting documentation and test maintenance
src/*tests.rs, scripts/dev-fast-common.sh, test_support/src/dev_fast/sandbox/mod.rs, docs/*
Supporting text reflects the nightly change. Several tests use explicit empty-vector comparisons. decode_lower_hex uses fixed-size chunks.

Poem

The nightly pin now lights the way
Polonius guards each build today
Rustdoc writes its facts to file
Cargo paths resolve in style
Response lines march without delay
Clean test helpers join the fray

Merge Risk: 🟡 Moderate · up to fd419

The change updates the pinned compiler and build/test configuration, but the current head still has a bounded error-reporting defect that can mislabel malformed coverage data, along with two contradictory developer-guide statements about Kani and NLL compatibility. These should be corrected or explicitly accepted before merge.


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (2 errors, 4 warnings)

Check name Status Explanation Resolution
Testing (Overall) ❌ Error Strengthen the tests for the new Cargo artefact parser. tests/support/cargo_artifacts.rs tests only valid compiler-artifact messages. It does not test malformed JSON, unrelated Cargo messages, wro… Add focused parser tests for malformed and non-compiler-artifact messages, missing fields, wrong target names, multiple metadata/library paths, and the required path-preference order. Parameterize the coverage invalid-count test for both …
Unit Architecture ❌ Error The new scripts/doc_coverage_runner.py does not provide an injectable process boundary. cargo_executable() reads global os.environ, while measure() and load_metadata() call global `subproces… Split the Cargo/Rustdoc process and generated-file adapter into a narrow scripts/doc_coverage_cargo.py interface. Inject that adapter into the measurement runner, and pass configuration such as the Cargo executable explicitly from the CLI…
Developer Documentation ⚠️ Warning The developer guide documents the new toolchain, Cargo layouts, response-file helpers, coverage boundaries, and binary locator. ADR-006 also records the change in a dated addendum. However, the PR dir… Restore ADR-007's historical wording and append a dated addendum that records the new pinned-nightly-only source-build requirement and any related formatting or installation consequences. Keep the original decision text intact, and update t…
Testing (Unit And Behavioural) ⚠️ Warning Fail: the pull request adds new command-line and helper behaviour without complete boundary and edge-case coverage. scripts/doc-coverage.py now delegates the externally visible make doc-coverage w… Add an end-to-end test for the documentation-coverage CLI or make doc-coverage. Run the real CLI process with a controlled Cargo fixture and assert its output, threshold exit codes, toolchain selection, and generated-file coverage path. A…
Testing (Property / Proof) ⚠️ Warning The PR introduces range- and ordering-based invariants without property coverage for all new helpers. tests/support/cargo_artifacts.rs adds library_path_in_message, which must select the last `.rm… Add substantive property-based tests for the new invariants. Generate ordered Cargo artefact lists and assert that library_path_in_message returns the last .rmeta, falls back to the last .rlib, returns None for a mismatched target o…
Domain Architecture ⚠️ Warning Fail this check because the new scripts/doc_coverage_model.py leaks Rustdoc's serialized representation into the domain model. aggregate_coverage_payload() accepts a raw dict at lines 58–85, and… Move Rustdoc JSON decoding, payload-shape validation, and generated-file handling into a dedicated Cargo/Rustdoc adapter such as scripts/doc_coverage_cargo.py. Make that adapter translate raw Rustdoc and Cargo data into Coverage and `Do…
✅ Passed checks (14 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the main change: adoption of the Polonius-enabled nightly toolchain and removal of the explicit -Z directive. No roadmap or issue reference is required by the supplied …
Description check ✅ Passed The description directly explains the toolchain update, removal of explicit Polonius configuration, contract-test changes, compatibility fixes, documentation updates, and validation results. It is cle…
Docstring Coverage ✅ Passed Docstring coverage is 87.60% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 121 functions across 25 files. (4 skipped: …
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.
User-Facing Documentation ✅ Passed Pass the check. The changed source and registry installation behaviour is documented in docs/users-guide.md: it states that the pinned nightly enables Polonius, explains checkout toolchain selection…
Module-Level Documentation ✅ Passed Pass the check. Every changed Python module has a leading module docstring, including scripts/doc_coverage_model.py, scripts/doc_coverage_runner.py, scripts/doc-coverage.py, and the changed test…
Testing (Compile-Time / Ui) ✅ Passed Pass this check. The PR retains Rust-specific compile-time coverage through direct rustc harnesses, which are a language-specific equivalent to trybuild. The harnesses cover compile-pass and compile…
Observability ✅ Passed PASS — keep this check passed. The aggregate diff from main changes only test modules under src, test-support code, test harnesses, Cargo/Make/workflow configuration, documentation, and the develope…
Security And Privacy ✅ Passed No security or privacy failure is introduced. The aggregate diff adds no secret or credential values and does not change workflow permissions or token handling. New Cargo and Rustdoc subprocess calls …
Performance And Resource Use ✅ Passed No material performance or resource-use failure was introduced. The changed executable code is a documentation-coverage gate and test-support code, not a production hot path. `doc_coverage_runner.run_…
Concurrency And State ✅ Passed Pass the concurrency and state check. The changed process paths are synchronous: subprocess.run and Command::output() wait for completion. The direct-rustc response files and isolated process dire…
Architectural Complexity And Maintainability ✅ Passed Pass. Keep the new boundaries. The original scripts/doc-coverage.py was 427 lines and the change separates CLI reporting, Cargo/Rustdoc process handling, and pure coverage validation into `doc-cover…
Rust Compiler Lint Integrity ✅ Passed Pass the check. The PR adds no broad dead_code, unused_imports, or unused allowance or expectation. It removes two obsolete expect(dead_code) fields and deletes the stale polonius_flags help…
Full details: Title check

Explanation

The title accurately summarises the main change: adoption of the Polonius-enabled nightly toolchain and removal of the explicit -Z directive. No roadmap or issue reference is required by the supplied context.

Full details: Description check

Explanation

The description directly explains the toolchain update, removal of explicit Polonius configuration, contract-test changes, compatibility fixes, documentation updates, and validation results. It is clearly related to the changeset.

Full details: Docstring Coverage

Explanation

Docstring coverage is 87.60% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 121 functions across 25 files. (4 skipped: 4 unsupported.)

Full details: Testing (Overall)

Explanation

Strengthen the tests for the new Cargo artefact parser. tests/support/cargo_artifacts.rs tests only valid compiler-artifact messages. It does not test malformed JSON, unrelated Cargo messages, wrong targets, or multiple .rmeta/.rlib paths. Therefore an implementation that ignores the reason or target checks, or selects the wrong matching artefact, would pass the current tests while producing incorrect -L paths or --extern inputs in both changed UI harnesses. Also test Boolean with_docs values; the current invalid-count case covers only total: true.

Resolution

Add focused parser tests for malformed and non-compiler-artifact messages, missing fields, wrong target names, multiple metadata/library paths, and the required path-preference order. Parameterize the coverage invalid-count test for both total: true and with_docs: true. Assert the CLI delegation test records the expected runner call arguments, or remove that test if the existing failure-translation test is the intended delegation guard.

Full details: User-Facing Documentation

Explanation

Pass the check. The changed source and registry installation behaviour is documented in docs/users-guide.md: it states that the pinned nightly enables Polonius, explains checkout toolchain selection, and gives the explicit nightly-2026-08-23 registry commands. README.md and docs/quickstart.md provide matching guidance. docs/v0-1-0-migration-guide.md signposts the updated toolchain requirement, and docs/contents.md indexes that migration guide. No stale -Zpolonius, POLONIUS_FLAGS, or old nightly instructions remain in the primary user documents. The remaining changes are CI, build-tooling, test-harness, and internal documentation changes, not new end-user product interfaces.

Full details: Developer Documentation

Explanation

The developer guide documents the new toolchain, Cargo layouts, response-file helpers, coverage boundaries, and binary locator. ADR-006 also records the change in a dated addendum. However, the PR directly edits accepted ADR-007 without an addendum: its Decision section now changes the source-build requirement from “the pinned nightly and the Polonius flag” to only “the pinned nightly”, and its Date remains 2026-08-05. This is a retroactive edit to an accepted ADR, which violates the check.

Resolution

Restore ADR-007's historical wording and append a dated addendum that records the new pinned-nightly-only source-build requirement and any related formatting or installation consequences. Keep the original decision text intact, and update the ADR date or addendum date according to the repository convention.

Full details: Module-Level Documentation

Explanation

Pass the check. Every changed Python module has a leading module docstring, including scripts/doc_coverage_model.py, scripts/doc_coverage_runner.py, scripts/doc-coverage.py, and the changed test modules. Every changed Rust module has //! documentation. The new netsuke, Cargo artefact, and rustc response-file modules also explain their purpose, scope, and relationship to parent modules or consumers. Inline test modules carry module documentation as well. No changed module introduces the stated documentation failure.

Full details: Testing (Unit And Behavioural)

Explanation

Fail: the pull request adds new command-line and helper behaviour without complete boundary and edge-case coverage. scripts/doc-coverage.py now delegates the externally visible make doc-coverage workflow to doc_coverage_runner, but every coverage test imports main() and replaces Cargo with FakeCargo; no test executes scripts/doc-coverage.py as a process or invokes the Make target. The new tests/support/cargo_artifacts.rs tests cover valid messages only, although compiler_artifact_paths intentionally returns no result for malformed or non-compiler-artifact messages. The new response-file tests cover rendering and one successful write, but do not cover the documented write-failure or non-UTF-8-path errors. These gaps affect behaviour introduced by this pull request.

Resolution

Add an end-to-end test for the documentation-coverage CLI or make doc-coverage. Run the real CLI process with a controlled Cargo fixture and assert its output, threshold exit codes, toolchain selection, and generated-file coverage path. Add unit cases for malformed and non-compiler-artifact Cargo messages, wrong target and missing loadable artefacts, response-file write failures, and invalid UTF-8 response-file paths. Keep the existing valid-input and split-build integration tests.

Full details: Testing (Property / Proof)

Explanation

The PR introduces range- and ordering-based invariants without property coverage for all new helpers. tests/support/cargo_artifacts.rs adds library_path_in_message, which must select the last .rmeta or .rlib from arbitrary ordered artefacts and reject non-matching messages, but its tests cover only two fixed examples. scripts/doc_coverage_runner.py adds coverage_output_path, which parses arbitrary Rustdoc output lines and resolves relative or absolute paths; its tests use only two valid and three invalid examples. The PR does add substantive proptest coverage for dependency-directory ordering and response-file argument preservation, and it exhaustively tests the locator's eight candidate-presence states. The moved coverage_count logic is pre-existing, so it does not create a new failure under the causality rule. No introduced proof lemma requires an exhaustive proof.

Resolution

Add substantive property-based tests for the new invariants. Generate ordered Cargo artefact lists and assert that library_path_in_message returns the last .rmeta, falls back to the last .rlib, returns None for a mismatched target or no loadable artefact, and safely handles malformed or non-artefact messages. Add Hypothesis tests for coverage_output_path that generate newline-separated output, portable relative and absolute paths, valid notices, and malformed notices, then assert path resolution or controlled rejection. Retain the existing example tests for targeted diagnostics and platform-specific cases.

Full details: Testing (Compile-Time / Ui)

Explanation

Pass this check. The PR retains Rust-specific compile-time coverage through direct rustc harnesses, which are a language-specific equivalent to trybuild. The harnesses cover compile-pass and compile-fail fixtures for StubEnv::default(), public API visibility, and cfg(kani) policy. The new Cargo-artifact and response-file helpers also have focused unit and property tests. Snapshot tests are not required because the tests assert stable semantic results instead of brittle compiler-diagnostic text.

Full details: Unit Architecture

Explanation

The new scripts/doc_coverage_runner.py does not provide an injectable process boundary. cargo_executable() reads global os.environ, while measure() and load_metadata() call global subprocess.run; pinned_toolchain() and measure() also perform direct filesystem reads. The runner combines target discovery, Cargo command construction, subprocess execution, generated-file handling, JSON parsing, and measurement orchestration. Tests patch runner.subprocess.run instead of supplying a purpose-shaped dependency. This conflicts with the required dependency injection and single-responsibility boundaries. The pull request introduced this runner as the new execution module, so the violation is causal even though the code was moved from the former monolithic CLI script.

Resolution

Split the Cargo/Rustdoc process and generated-file adapter into a narrow scripts/doc_coverage_cargo.py interface. Inject that adapter into the measurement runner, and pass configuration such as the Cargo executable explicitly from the CLI boundary. Keep target selection and coverage aggregation pure. Keep filesystem and process fallibility explicit in returned errors or exceptions at the adapter boundary. Replace global subprocess.run monkeypatches with fake adapter instances in the tests. Keep doc_coverage_model.py free of environment, filesystem, and process access.

Full details: Domain Architecture

Explanation

Fail this check because the new scripts/doc_coverage_model.py leaks Rustdoc's serialized representation into the domain model. aggregate_coverage_payload() accepts a raw dict at lines 58–85, and coverage_from_entry() and coverage_count() read the vendor keys total and with_docs at lines 88–146. scripts/doc_coverage_runner.py passes the json.loads() result directly to that model code at lines 81–93. This violates the required adapter boundary for serialization formats. The PR does improve the CLI boundary, but it does not provide the separate Cargo/Rustdoc adapter needed to translate the payload before it reaches the model.

Resolution

Move Rustdoc JSON decoding, payload-shape validation, and generated-file handling into a dedicated Cargo/Rustdoc adapter such as scripts/doc_coverage_cargo.py. Make that adapter translate raw Rustdoc and Cargo data into Coverage and DocTarget values before calling domain code. Keep scripts/doc_coverage_model.py limited to pure domain values, operations, and invariants. Enforce total &gt;= 0, with_docs &gt;= 0, and with_docs &lt;= total in the domain value construction or in a typed domain factory. Keep process, filesystem, environment, and vendor-specific error translation in the adapter. Update the tests to test the model with domain values and test the adapter separately with raw Cargo/Rustdoc representations.

Full details: Observability

Explanation

PASS — keep this check passed. The aggregate diff from main changes only test modules under src, test-support code, test harnesses, Cargo/Make/workflow configuration, documentation, and the developer-only Rustdoc coverage gate. Cargo.toml confirms test_support is a dev-dependency, and test_support/Cargo.toml sets publish = false. The refactored coverage runner retains the existing Cargo/Rustdoc subprocess boundary and provides target names, stderr, generated-file paths, malformed-JSON details, and controlled CLI exit codes. No production runtime behaviour, production metrics, tracing, or alerts changed, so the custom check's production observability failure condition does not apply.

Full details: Security And Privacy

Explanation

No security or privacy failure is introduced. The aggregate diff adds no secret or credential values and does not change workflow permissions or token handling. New Cargo and Rustdoc subprocess calls use argument arrays without shell evaluation. JSON and TOML inputs use parsers. The direct-rustc helpers pass paths as arguments and reject newline-bearing response-file arguments. The environment-isolated Netsuke helper was moved without changing its existing behaviour. The new coverage-file path handling uses pathlib and reads the file reported by Rustdoc; no evidence shows that this creates a privileged boundary or exposes sensitive data.

Full details: Performance And Resource Use

Explanation

No material performance or resource-use failure was introduced. The changed executable code is a documentation-coverage gate and test-support code, not a production hot path. doc_coverage_runner.run_measurements retains the existing one Cargo Rustdoc invocation per workspace target and now reads the generated coverage file. The new collections are bounded by workspace metadata and are required for per-target reporting and Cargo dependency discovery. The response-file change preserves every dependency directory while moving the argument payload off the Windows command line. The only new quadratic-looking operation is ordered de-duplication with Vec::contains in the two direct-rustc test harnesses; it processes the finite Cargo workspace artefact list, and the current lockfile contains 405 packages. No unbounded queue, retry loop, async blocking operation, or repeated production I/O was introduced.

Full details: Concurrency And State

Explanation

Pass the concurrency and state check. The changed process paths are synchronous: subprocess.run and Command::output() wait for completion. The direct-rustc response files and isolated process directories are owned by per-call temporary directories, and their lifetimes cover each compiler invocation. run_measurements processes targets in a deterministic sequential loop and reads each generated file immediately. The only shared test fixture uses rstest #[once] with an immutable TestSupportRlib; the code documents the parallel-test rationale and uses private target/build directories for the concurrent split-layout test. Added tests cover response-file ordering and lifetime, split artefact isolation, output-file failure handling, and Cargo artefact ordering. No new async tasks, background workers, locks, mutable global state, or unsynchronised shared state were introduced.

Full details: Architectural Complexity And Maintainability

Explanation

Pass. Keep the new boundaries. The original scripts/doc-coverage.py was 427 lines and the change separates CLI reporting, Cargo/Rustdoc process handling, and pure coverage validation into doc-coverage.py, doc_coverage_runner.py, and doc_coverage_model.py. The modules have one-way dependencies and documented ownership. tests/support/cargo_artifacts.rs and tests/support/rustc_response_file.rs remove duplicated parsing and provide two concrete consumers for the Cargo 1.99 and Windows command-line seams. test_support/src/netsuke/locator.rs separates binary lookup from process execution and keeps the locator private. The developer guide and module comments state scope and reuse rules. No new third-party dependency, global state, registry, hidden lifecycle, or circular dependency was introduced. The explicit architectural failure conditions are not met.

Full details: Rust Compiler Lint Integrity

Explanation

Pass the check. The PR adds no broad dead_code, unused_imports, or unused allowance or expectation. It removes two obsolete expect(dead_code) fields and deletes the stale polonius_flags helper. New support functions have real harness call sites and unit tests. The only new clone-like operation is .cloned() in last_with_extension, which returns an owned PathBuf from a borrowed slice and matches the function contract. Existing unrelated suppressions are unchanged.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch use-polonius-enabled-nightly

Warning

Your free Security trial is over. An organization admin can activate Security or dismiss this notice.


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

@sourcery-ai

sourcery-ai Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Moves the pinned Rust toolchain to a Polonius-default nightly and removes all -Zpolonius plumbing in favor of carrying the Polonius requirement solely via the dated nightly pin, updates CI and documentation to match, adapts test harnesses to Cargo 1.99’s new build layout, and fixes a few new clippy lints.

Sequence diagram for UI harness dependency discovery

sequenceDiagram
    participant Harness as UI test harness
    participant Cargo as Cargo 1.99
    participant Rustc as rustc fixture compiler
    Harness->>Cargo: cargo metadata/build with JSON messages
    Cargo-->>Harness: compiler-artifact loadable filenames
    Harness->>Harness: profile_dir(executable_path)
    Harness->>Rustc: Compile fixture with -L dependency=parent_directories
    Rustc-->>Harness: Fixture result
Loading

Flow diagram for the toolchain contract safeguard

flowchart TD
    Start[Build configuration] --> Channel[Read pinned channel]
    Channel --> ValidChannel{Dated nightly >= 2026-08-04?}
    ValidChannel -- No --> Fail[Contract test fails]
    ValidChannel -- Yes --> Scan[Scan Makefile, Cargo config, and workflows]
    Scan --> Directive{-Zpolonius directive found?}
    Directive -- Yes --> Fail
    Directive -- No --> Pass[Policy accepted]
Loading

File-Level Changes

Change Details Files
Adopt a newer Polonius-default nightly toolchain and retire all -Zpolonius flags, simplifying the RUSTFLAGS/CI contracts while enforcing the policy via tests.
  • Bump rust-toolchain channel from nightly-2026-06-25 to nightly-2026-08-13 and document that Polonius is enabled by default on >= 2026-08-04 nightlies.
  • Delete .cargo/config.toml and remove the POLONIUS_FLAGS Make variable; Makefile recipes that set RUSTFLAGS now only add -D warnings and preserve inherited flags.
  • Update all GitHub workflows to use the new nightly, drop -Zpolonius from with.rustflags, and keep -D warnings only where gating on warnings is intended.
  • Tighten the toolchain/Polonius contract test to require a dated nightly >= 2026-08-04 and to assert that no build configuration file reintroduces a -Zpolonius directive, while updating the shared-actions expectations.
  • Simplify the Makefile RUSTFLAGS contract tests by removing per-case policy enums and asserting uniform behaviour (conditional inheritance plus warnings-as-errors).
rust-toolchain.toml
Makefile
.github/workflows/ci.yml
.github/workflows/coverage-main.yml
.github/workflows/netsukefile-test.yml
.github/workflows/build-and-package.yml
tests/polonius_toolchain_contract.rs
tests/makefile_test_target.rs
tests/makefile_test_target/rustflags.rs
.cargo/config.toml
Update ADRs, guides, and policy docs to reflect the new Polonius-default model and the simplified RUSTFLAGS and CI contracts, including Kani/trybuild consequences and registry-install requirements.
  • Revise ADR-006, Polonius migration notes, and related design docs to describe Polonius as enabled by default on the pinned nightly and to treat -Zpolonius as historical context only.
  • Update developers’ guide, AGENTS, README, users’ guide, quickstart, and ADR-007 to remove references to -Zpolonius=next, document the "no -Z directive" rule, and adjust CI shared-action and dev-fast composition rules.
  • Adjust documentation/tests to pin the new nightly in crates.io install commands and to assert only the toolchain selection (no RUSTFLAGS requirement) for registry installs.
  • Clarify Kani integration and harness behaviour now that Polonius is toolchain-driven instead of flag-driven, keeping direct-compile harnesses where they are still the better option.
docs/adr-006-adopt-polonius-nightly-toolchain.md
docs/polonius.md
docs/developers-guide.md
docs/users-guide.md
docs/quickstart.md
docs/netsuke-design.md
docs/adr-007-publish-as-netsuke-build.md
AGENTS.md
README.md
docs/netsuke-design.md
scripts/dev-fast-common.sh
tools/dev-fast/config.toml
tests/documentation_installation_tests.rs
tests/sha2_migration_guard_tests.rs
tests/kani_cfg_ui_tests.rs
tests/locale_stub_ui_tests.rs
tests/command_env_ui_tests.rs
Adapt test harnesses to Cargo 1.99’s new build/executable layout, including robust binary and dependency discovery that works across both old and new directory structures and handles proc-macro dynamic libraries.
  • Extract the binary locator into test_support::netsuke::locator, introduce profile_dir to normalize both target/debug/deps and target/debug/build/.../out layouts, and add unit tests for both plus edge cases.
  • Update the description and docs of the locator to account for the new integration-test executable locations and to use the derived profile directory for fallbacks.
  • Change UI harnesses for locale and command-env tests to collect parent directories of all loadable artefacts (rlibs and platform DLLs) from Cargo JSON output, so per-crate build directories and proc-macro dylibs are handled correctly.
  • Extend tests around the harnesses to cover proc-macro dylib directories and the new build layout behaviour.
test_support/src/netsuke/locator.rs
test_support/src/netsuke/mod.rs
docs/developers-guide.md
tests/locale_stub_ui_tests.rs
tests/command_env_ui_tests.rs
Fix clippy lints and minor test expectations to comply with the new nightly’s lint set.
  • Replace assert!(…is_empty()) with equality against explicit empty vectors in several tests to satisfy assert_is_empty suggestions.
  • Rewrite the hex decoding helper to use as_chunks::<2>() instead of chunks_exact(2) for chunks_exact_to_as_chunks lint compliance.
tests/ir_tests.rs
src/graph_view/tests.rs
src/status_timing_tests.rs
src/hex_property_tests.rs

Possibly linked issues


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 force-pushed the use-polonius-enabled-nightly branch from d828eff to f1923cd Compare August 22, 2026 02:49
codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@leynos
leynos force-pushed the use-polonius-enabled-nightly branch from f1923cd to ae6ea6c Compare August 24, 2026 16:26
codescene-access[bot]

This comment was marked as outdated.

@leynos
leynos force-pushed the use-polonius-enabled-nightly branch from ae6ea6c to 15efb15 Compare August 24, 2026 16:31
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 25, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai Please investigate the cause of the following issue using codegraph exploration and research, identify a fix and provide an AI coding agent prompt for the fix:

        FAIL [ 168.754s] (2121/2121) netsuke-build::locale_stub_ui_tests harness_compiles_under_a_split_build_dir
  stdout ───

    running 1 test
    test harness_compiles_under_a_split_build_dir has been running for over 60 seconds
    test harness_compiles_under_a_split_build_dir ... FAILED

    failures:

    failures:
        harness_compiles_under_a_split_build_dir

    test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 9 filtered out; finished in 168.73s
    
  stderr ───
    Error: Os { code: 206, kind: InvalidFilename, message: "The filename or extension is too long." }

  Cancelling due to test failure: 
────────────
     Summary [ 271.684s] 2121 tests run: 2120 passed (2 slow), 1 failed, 2 skipped
        FAIL [ 168.754s] (2121/2121) netsuke-build::locale_stub_ui_tests harness_compiles_under_a_split_build_dir

https://github.com/leynos/netsuke/actions/runs/32751351959/job/97508796453?pr=577

@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 force-pushed the use-polonius-enabled-nightly branch from e67be8d to 1fafe72 Compare August 25, 2026 18:57
@leynos
leynos marked this pull request as ready for review August 25, 2026 18:57

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

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 150,000 diff characters

codescene-access[bot]

This comment was marked as outdated.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1fafe729c4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/adr-006-adopt-polonius-nightly-toolchain.md Outdated
coderabbitai[bot]

This comment was marked as resolved.

codescene-access[bot]

This comment was marked as outdated.

@leynos

leynos commented Aug 26, 2026 •

Copy link
Copy Markdown
Owner Author

@coderabbitai re:

docs/adr-006-adopt-polonius-nightly-toolchain.md
Comment on lines +50 to +51

  50 + |  requirement on its own, so plain Cargo invocations, rust-analyzer, Clippy,
  51 + |  Whitaker, and Kani all borrow-check with the same analysis without any

Correct the claim that Kani uses Polonius

The Kani part of this statement is false: Makefile now invokes $(KANI) without any Polonius flag, while docs/polonius.md documents that Kani 0.67.0 uses nightly-2025-11-21 and therefore borrow-checks under NLL. When a future POLONIUS(...) API is verified, this ADR would incorrectly lead maintainers to expect Kani to use the same analysis; remove Kani from this claim and the equivalent rationale claim, or document the exception here.

AGENTS.md reference: AGENTS.md:L44-L47

Is it the case that Kani cannot be run with the 2026-08-23 nightly?

@coderabbitai

This comment was marked as resolved.

@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 26, 2026

Copy link
Copy Markdown
Owner Author

@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 in a code block that I can paste into the CodeScene web ui's diagnostic suppression function so this diagnostic can be silenced.

Complex Conditional

scripts/doc_coverage_model.py: coverage_count

What lead to degradation?

coverage_count has 1 complex conditionals with 2 branches, threshold = 2

Why does this problem occur?

A complex conditional is an expression inside a branch such as an if-statmeent which consists of multiple, logical operations. Example: if (x.started() && y.running()).Complex conditionals make the code even harder to read, and contribute to the Complex Method code smell. Encapsulate them.

How to fix it?

Apply the DECOMPOSE CONDITIONAL refactoring so that the complex conditional is encapsulated in a separate function with a good name that captures the business rule. Optionally, for simple expressions, introduce a new variable which holds the result of the complex conditional.

Helpful refactoring examples

To get a general understanding of what this code health issue looks like - and how it might be addressed - we have prepared some diffs for illustrative purposes.

SAMPLE

# complex_conditional.js
 function messageReceived(message, timeReceived) {
-   // Ignore all messages which aren't from known customers:
-   if (!message.sender &&
-       customers.getId(message.name) == null) {
+   // Refactoring #1: encapsulate the business rule in a
+   // function. A clear name replaces the need for the comment:
+   if (!knownCustomer(message)) {
      log('spam received -- ignoring');
      return;
    }
 
-  // Provide an auto-reply when outside business hours:
-  if ((timeReceived.getHours() > 17) ||
-      (timeReceived.getHours() < 8)) {
+  // Refactoring #2: encapsulate the business rule.
+  // Again, note how a clear function name replaces the
+  // need for a code comment:
+  if (outsideBusinessHours(timeReceived)) {
     return autoReplyTo(message);
   }
 
   pingAgentFor(message);
+}
+
+function outsideBusinessHours(timeReceived) {
+  // Refactoring #3: replace magic numbers with
+  // symbols that communicate with the code reader:
+  const closingHour = 17;
+  const openingHour = 8;
+
+  const hours = timeReceived.getHours();
+
+  // Refactoring #4: simple conditional rules can
+  // be further clarified by introducing a variable:
+  const afterClosing = hours > closingHour;
+  const beforeOpening = hours < openingHour;
+
+  // Yeah -- look how clear the business rule is now!
+  return afterClosing || beforeOpening;
 }

codescene-access[bot]

This comment was marked as outdated.

@leynos

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

Inject the Cargo and Rustdoc boundary into coverage orchestration, while
keeping explicit process configuration and payload validation in its adapter.

Expand parser and executable CLI coverage, and record the pinned-nightly
requirement for cargo-binstall source fallbacks.
codescene-access[bot]

This comment was marked as outdated.

@leynos

leynos commented Aug 28, 2026

Copy link
Copy Markdown
Owner Author

@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 in a code block that I can paste into the CodeScene web ui's diagnostic suppression function so this diagnostic can be silenced.

scripts/tests/test_doc_coverage.py

Comment on file

boundaries with canned responses so the script's own logic — target
discovery, aggregation, threshold exits, malformed-output handling, and
command-failure translation — is exercised without invoking Cargo at all.
``scripts/doc_coverage_cargo.py`` wraps ``cargo rustdoc --show-coverage`` and

❌ New issue: Low Cohesion
This module has at least 22 different responsibilities amongst its 46 functions, threshold = 4

@leynos

leynos commented Aug 28, 2026

Copy link
Copy Markdown
Owner Author

@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 in a code block that I can paste into the CodeScene web ui's diagnostic suppression function so this diagnostic can be silenced.

scripts/tests/test_doc_coverage.py

Comment on file

)
def test_main_rejects_invalid_coverage_counts(
    script: types.ModuleType,
    cargo: types.ModuleType,

❌ New issue: Excess Number of Function Arguments
test_main_rejects_invalid_coverage_counts has 5 arguments, max arguments = 4

@leynos

leynos commented Aug 28, 2026

Copy link
Copy Markdown
Owner Author

@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 in a code block that I can paste into the CodeScene web ui's diagnostic suppression function so this diagnostic can be silenced.

scripts/tests/test_doc_coverage.py

Comment on lines +975 to +976

    runner: types.ModuleType,
    cargo: types.ModuleType,

❌ New issue: Excess Number of Function Arguments
test_main_maps_invalid_coverage_shape_to_measurement_error has 5 arguments, max arguments = 4

@coderabbitai

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

Reach the injected Cargo adapter through the already-loaded CLI runner so
the invalid-payload test stays below the CodeScene parameter threshold.
codescene-access[bot]

This comment was marked as outdated.

@pandalump

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Head commit changed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

codescene-access[bot]

This comment was marked as outdated.

Reuse the Cargo adapter held by the loaded CLI runner so the invalid-count
coverage test remains below the CodeScene parameter threshold.
codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

Separate the doc-coverage test suite by model, Cargo adapter,
Cargo payload, runner, and CLI boundaries.

Keep dynamic import ordering in shared fixtures and execute every
focused module through `make doc-coverage-test`.
codescene-access[bot]

This comment was marked as outdated.

Keep the split test modules compliant with the repository Ruff policy
without changing the production or CLI contracts.
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 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 merged commit dffd52d into main Aug 28, 2026
18 checks passed
@leynos
leynos deleted the use-polonius-enabled-nightly branch August 28, 2026 10:43
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.

3 participants