Skip to content

Fix unfulfilled lint expectation in crates/comenqd/tests/util.rs #91

Open

Description

@coderabbitai

Description

CI compilation is failing due to an unfulfilled lint expectation in the test utilities file.

Error Details

error: this lint expectation is unfulfilled
Error:   --> crates/comenqd/tests/util.rs:16:14
   |
16 |     #[expect(dead_code, reason = "Constructed in integration tests but unused here")]
   |              ^^^^^^^^^
   |
   = note: Constructed in integration tests but unused here
   = note: `-D unfulfilled-lint-expectations` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(unfulfilled_lint_expectations)]`

Impact

This error is preventing:

  • Successful compilation of the test suite
  • CI pipeline completion
  • PR merge capability

Suggested Solutions

The compiler suggests three possible fixes:

  1. Remove the #[expect(dead_code)] attribute if the code is now being used
  2. Replace with #[allow(dead_code)] if the code should remain potentially unused
  3. Add #[allow(unfulfilled_lint_expectations)] to override the strict warning

Location

  • File: crates/comenqd/tests/util.rs
  • Line: 16

References

Activity

  1. leynos commented on Oct 20, 2026

    @leynos
    Owner
  2. coderabbitai commented on Oct 20, 2026

    @coderabbitai
    ContributorAuthor

    Coding Plan

    Summary

    • Keep the reported #[expect(dead_code)] removed. Use no replacement suppression. The root Clippy configuration denies allow attributes. #[expect] fails in any target where the item is used.
    • Move the shared helpers to tests/util/mod.rs. Stop Cargo from compiling the helpers as a standalone target with no consumer. Remove the source of inconsistent dead-code results.
    • Replace the construction-only test with a behavioural assertion of the complexity factors. Keep every variant legitimately used. Add coverage for the documented contract.
    • Verify with the CI command set and a feature-off check. Report the result for each target.
    Design Choices
    Design Choice 1: Decide what fixing the ticket means when the current checkout does not contain the reported attribute.

    Options Considered:

    1. Treat the ticket as already resolved. Make no change.
    2. Keep the attribute removed. Remove the root cause, which is the standalone util target. Replace the construction-only reference with real behavioural assertions. Verify with the CI command set.

    Chosen Option: 2

    Rationale: it closes the ticket permanently and complies with the rule against suppressions and artificial references, which Option 1 does not guarantee.

    Design Choice 2: Decide how to stop Cargo from compiling the shared helpers as a standalone harness.

    Options Considered:

    1. Move tests/util.rs to tests/util/mod.rs. Cargo does not auto-discover subdirectory modules as targets. This is the conventional tests/common/mod.rs layout.
    2. Set autotests = false and declare an explicit [[test]] entry for each harness in crates/comenqd/Cargo.toml.
    3. Keep the standalone target and add inline tests that call every helper inside util.rs.
    4. Add cfg-conditional #[expect] attributes for each target.

    Chosen Option: 1

    Rationale: it is the idiomatic Rust layout, it needs no Cargo configuration, and mod util; resolves without edits in either harness.

    Design Choice 3: Decide whether to keep `uses_all_test_complexity_variants`.

    Options Considered:

    1. Delete the test.
    2. Replace the test with a parameterized behavioural test that asserts the factor for each variant.

    Chosen Option: 2

    Rationale: it keeps every variant legitimately used and adds the missing assertion for the Complex factor.

    💡 User Tips

    Regenerate the plan with different choices with @coderabbitai <feedback>.

    Implementation Steps

    Phase 1: Establish a single consumer-backed compilation boundary

    Confirm that the suppression is absent. Record the baseline lint state. Remove the standalone util test target. Compile the helpers only inside harnesses that consume them. Group these tasks because they change how Cargo discovers and compiles the shared module.

    Decision context

    Line 16 of the current util.rs is pub const CI_MULTIPLIER: u64 = 2; and has no attributes. The error shows the attribute indented at column 14. This indicates that the PR #85 branch placed it on an indented item, probably a TestComplexity variant. The construction-only test uses_all_test_complexity_variants makes every variant "used" in the standalone util target. That use made the expectation unfulfilled there. The root cause is the three different compilation roots for one file. A remaining failure is still possible.

    In the standalone target, timeout_with_retries and its call chain have no caller. This is a plausible dead_code error under -D warnings. If an #[expect] hides that error, the expectation becomes unfulfilled in the harnesses that use the item.

    Task 1: Confirm the baseline and reproduce the strict build

    Record the exact warnings before any change. Use this record to show whether the move fixes a real failure.

    • Search crates/comenqd/tests/ for expect(dead_code, allow(dead_code and unfulfilled_lint_expectations. Confirm that no match exists.
    • Run RUSTFLAGS="-D warnings" cargo clippy -p comenqd --all-targets --all-features -- -D warnings on the pinned nightly.
    • Run RUSTFLAGS="-D warnings" cargo check -p comenqd --tests without test-support.
    • Record every dead_code or unfulfilled_lint_expectations diagnostic. Record the target that emits it (util, retry_helper or daemon).
    • If the toolchain or mold is unavailable, state this explicitly. Do not report it as a pass.
    Task 2: Move the shared helpers out of auto-discovery

    Remove the standalone util target that compiles the helpers with no consumer.

    • Move crates/comenqd/tests/util.rs to crates/comenqd/tests/util/mod.rs with git mv. Preserve the file history.
    • Leave mod util; unchanged in crates/comenqd/tests/daemon.rs and crates/comenqd/tests/retry_helper.rs. Rust resolves util/mod.rs automatically.
    • Do not add any #[expect], #[allow], cfg_attr lint gate or const _ anchor.
    • Keep the visibility of each item unchanged, including pub(crate) on join_err.
    Task 3: Remove stale references to the `util` target

    Make sure no tooling still invokes the deleted target.

    • Search Makefile, .github/workflows/ci.yml, .cargo/config.toml and any nextest configuration for --test util or tests/util.rs.
    • If a reference exists, delete it. The inline tests now run inside retry_helper in every configuration. They also run inside daemon when test-support is enabled.
    🤖 Prompt for AI agents
    Establish a consumer-backed compilation boundary for the shared timeout helpers.
    Remove Cargo's standalone `util` target without adding suppressions or
    artificial references.
    
    - Before changes, search `crates/comenqd/tests/` for `expect(dead_code`,
    `allow(dead_code` and `unfulfilled_lint_expectations`. Confirm that no match
    exists.
    - On the pinned nightly, run `RUSTFLAGS="-D warnings" cargo clippy -p comenqd
    --all-targets --all-features -- -D warnings`. Run `RUSTFLAGS="-D warnings" cargo
    check -p comenqd --tests` without `test-support`.
    - Record each `dead_code` and `unfulfilled_lint_expectations` diagnostic against
    `util`, `retry_helper` or `daemon`. If the toolchain or `mold` is unavailable,
    report that limitation. Do not report a pass.
    - Use `git mv` to move `crates/comenqd/tests/util.rs` to
    `crates/comenqd/tests/util/mod.rs`.
    - Leave `mod util;` unchanged in `daemon.rs` and `retry_helper.rs`. Preserve all
    item visibility, including `pub(crate)` on `join_err`.
    - Do not add `#[expect]`, `#[allow]`, a `cfg_attr` lint gate or a `const _`
    anchor.
    - Search `Makefile`, `.github/workflows/ci.yml`, `.cargo/config.toml` and any
    nextest configuration for `--test util` or `tests/util.rs`. Delete any
    references. Retain inline test execution through `retry_helper` in every
    configuration and through `daemon` when `test-support` is enabled.
    

    Phase 2: Replace the artificial reference with behavioural coverage

    Replace the construction-only test with real assertions. Align the documentation with the new module location and the complexity contract.

    The existing uses_all_test_complexity_variants test only constructs configurations. It asserts nothing and acts as an artificial reference. No existing assertion checks the 3× factor for Complex.

    Task 1: Assert the complexity factors

    Replace uses_all_test_complexity_variants with a test that asserts behaviour for every variant.

    • In crates/comenqd/tests/util/mod.rs, replace uses_all_test_complexity_variants with an #[rstest] test. Give the test one #[case] for each variant and its expected factor: Simple → 1, Moderate → 2, Complex → 3.
    • Build every configuration with .with_ci(false).with_coverage(false). Follow the existing rule that tests do not depend on the environment.
    • Select a base value that stays between MIN_TIMEOUT_SECS and MAX_TIMEOUT_SECS in debug and release builds for all three factors. For example, 20 seconds gives 20–120 seconds.
    • Assert the variant timeout against factor × Simple timeout. Keep the assertion independent of DEBUG_MULTIPLIER.
    • Do not change the existing CI, coverage, explicit-flag, stacking or join_err tests.
    Task 2: Update the adaptive-timeout documentation

    Keep docs/adaptive-timeouts.md consistent with the code that this ticket touches.

    • Update the module reference in docs/adaptive-timeouts.md. Name the helpers by their location in crates/comenqd/tests/util/mod.rs, which is included with mod util;. Replace the stale smart_timeouts and crate::daemon references.
    • State the complexity factors: Simple 1×, Moderate 2×, Complex 3×.
    • Do not change the documented constants, retry percentages or environment triggers.
    🤖 Prompt for AI agents
    Replace the construction-only reference with behavioural coverage of all
    complexity factors. Update the adaptive-timeout documentation to match the
    module location and contract.
    
    - In `crates/comenqd/tests/util/mod.rs`, replace
    `uses_all_test_complexity_variants` with an `#[rstest]` test. Add one `#[case]`
    for each factor: `Simple` → 1, `Moderate` → 2 and `Complex` → 3.
    - Use `.with_ci(false).with_coverage(false)` for every configuration to avoid
    environment-dependent results.
    - Use a base timeout within `MIN_TIMEOUT_SECS` and `MAX_TIMEOUT_SECS` for every
    factor in debug and release builds. Use 20 seconds as specified in the follow-up
    prompt; this gives 20–120 seconds.
    - Assert each variant timeout against `factor × Simple timeout`. Keep the
    assertion independent of `DEBUG_MULTIPLIER`.
    - Leave the existing CI, coverage, explicit-flag, stacking and `join_err` tests
    unchanged.
    - In `docs/adaptive-timeouts.md`, replace stale `smart_timeouts` and
    `crate::daemon` references with the helpers' location at
    `crates/comenqd/tests/util/mod.rs`. State that harnesses include the module with
    `mod util;`.
    - Document `Simple` as 1×, `Moderate` as 2× and `Complex` as 3×. Preserve the
    documented constants, retry percentages and environment triggers.
    

    Phase 3: Verify against the CI command set

    Prove that every target compiles and passes under the flags that CI uses.

    Run the CI checks and the feature-off check

    Confirm that no dead_code or unfulfilled_lint_expectations diagnostic remains in any configuration.

    • Run make lint, make typecheck (or the equivalent cargo check --workspace --all-targets --all-features with -D warnings) and make test.
    • Run RUSTFLAGS="-D warnings" cargo check -p comenqd --tests without test-support. Cover retry_helper while daemon is compiled out.
    • Run RUSTFLAGS="-D warnings" cargo clippy -p comenqd --all-targets -- -D warnings without test-support.
    • Run make fmt and make markdownlint, or the equivalent repository checks, for the moved file and the edited documentation.
    • Compare the result with the baseline from Task 1.1. Report the outcome for each target.
    🤖 Prompt for AI agents
    Verify the changes with the CI command set and feature-off checks. Confirm that
    no `dead_code` or `unfulfilled_lint_expectations` diagnostic remains.
    
    - Run `make lint`, `make typecheck` and `make test`. For type checking, use
    `cargo check --workspace --all-targets --all-features` with `-D warnings` if
    using the equivalent command.
    - Without `test-support`, run `RUSTFLAGS="-D warnings" cargo check -p comenqd
    --tests` and `RUSTFLAGS="-D warnings" cargo clippy -p comenqd --all-targets --
    -D warnings`. Check `retry_helper` while `daemon` is compiled out.
    - Run `make fmt` and `make markdownlint`, or equivalent repository checks, for
    the moved file and edited documentation.
    - Compare diagnostics with the baseline from Task 1.1. Report the outcome for
    each target.
    - If the toolchain is unavailable, state this explicitly. Do not report a pass.
    
    Research

    Ticket Summary

    Remove the #[expect(dead_code)] failure on crates/comenqd/tests/util.rs. The unfulfilled expectation breaks CI under -D warnings. Make the shared timeout helpers compile cleanly in every harness. Do not use lint suppression or an artificial reference.

    Codebase Summary

    crates/comenqd/tests/ holds integration-test crates. Each top-level .rs file is a separate Cargo test target. crates/comenqd/Cargo.toml declares no [[test]] entries and does not disable autotests.

    util.rs holds the adaptive-timeout constants, TestComplexity, TimeoutConfig, timeout_with_retries and join_err. It also holds inline unit tests. Two harnesses include it with mod util;:

    • daemon.rs is gated by #![cfg(feature = "test-support")].
    • retry_helper.rs is ungated.

    Cargo also compiles util.rs as a standalone target. That target has no consumer. Thus, each helper has a different dead-code status across targets.

    CI runs make lint, cargo check and make test with --all-targets --all-features and -D warnings on nightly-2025-07-22. Root Clippy lints deny allow_attributes. Only #[expect(..., reason = ...)] is permitted. unfulfilled_lint_expectations becomes an error under -D warnings. docs/adaptive-timeouts.md documents the timeout contract.

    File-Level Change Summary

    File Change Rationale
    crates/comenqd/tests/util.rs → crates/comenqd/tests/util/mod.rs Move the file with git mv. Replace uses_all_test_complexity_variants with a parameterized factor assertion. Remove the standalone harness that has no consumer. Remove the artificial reference. Assert the 3× factor for Complex.
    crates/comenqd/tests/daemon.rs Make no change. mod util; resolves to the new path. Retain the consumer of join_err and timeout_with_retries.
    crates/comenqd/tests/retry_helper.rs Make no change. Retain the consumer of the constants and TimeoutConfig. Run the inline helper tests in every feature configuration.
    docs/adaptive-timeouts.md Correct the module location. Add the complexity factors. Keep the documented contract accurate.
    Makefile, .github/workflows/ci.yml Edit only if a reference to --test util exists. Prevent CI from invoking a deleted target.

    Follow-up Agent Prompt

    Fix the unfulfilled `dead_code` lint expectation that the ticket reports for
    crates/comenqd/tests/util.rs.
    
    1. Search crates/comenqd/tests/ for `expect(dead_code`, `allow(dead_code` and
       `unfulfilled_lint_expectations`. Confirm that none exist. Do not add any of them.
    2. Run `RUSTFLAGS="-D warnings" cargo clippy -p comenqd --all-targets --all-features -- -D warnings`
       and `RUSTFLAGS="-D warnings" cargo check -p comenqd --tests` (without test-support).
       Record each diagnostic and the target that emits it.
    3. Run `git mv crates/comenqd/tests/util.rs crates/comenqd/tests/util/mod.rs`.
       Leave `mod util;` in daemon.rs and retry_helper.rs unchanged.
    4. Search Makefile, .github/workflows/ci.yml and nextest config for `--test util`.
       Delete any reference.
    5. In util/mod.rs, replace `uses_all_test_complexity_variants` with an rstest that
       asserts Simple = 1x, Moderate = 2x and Complex = 3x the Simple timeout. Use base
       20, `.with_ci(false)` and `.with_coverage(false)`. Keep all other tests unchanged.
    6. Update docs/adaptive-timeouts.md: name the helpers as tests/util/mod.rs, replace
       `smart_timeouts`/`crate::daemon`, and state the 1x/2x/3x factors.
    7. Run make lint, make typecheck, make test, make fmt and make markdownlint. Run the
       feature-off check and the feature-off clippy check from step 2. Report the result
       for each target. If the toolchain is unavailable, say so. Do not report a pass.
    

    🚀 Next Steps

    🤖 All AI agent prompts combined
    Task: 1
    
    Establish a consumer-backed compilation boundary for the shared timeout helpers.
    Remove Cargo's standalone `util` target without adding suppressions or
    artificial references.
    
    - Before changes, search `crates/comenqd/tests/` for `expect(dead_code`,
    `allow(dead_code` and `unfulfilled_lint_expectations`. Confirm that no match
    exists.
    - On the pinned nightly, run `RUSTFLAGS="-D warnings" cargo clippy -p comenqd
    --all-targets --all-features -- -D warnings`. Run `RUSTFLAGS="-D warnings" cargo
    check -p comenqd --tests` without `test-support`.
    - Record each `dead_code` and `unfulfilled_lint_expectations` diagnostic against
    `util`, `retry_helper` or `daemon`. If the toolchain or `mold` is unavailable,
    report that limitation. Do not report a pass.
    - Use `git mv` to move `crates/comenqd/tests/util.rs` to
    `crates/comenqd/tests/util/mod.rs`.
    - Leave `mod util;` unchanged in `daemon.rs` and `retry_helper.rs`. Preserve all
    item visibility, including `pub(crate)` on `join_err`.
    - Do not add `#[expect]`, `#[allow]`, a `cfg_attr` lint gate or a `const _`
    anchor.
    - Search `Makefile`, `.github/workflows/ci.yml`, `.cargo/config.toml` and any
    nextest configuration for `--test util` or `tests/util.rs`. Delete any
    references. Retain inline test execution through `retry_helper` in every
    configuration and through `daemon` when `test-support` is enabled.
    ===============================================================================
    
    Task: 2
    
    Replace the construction-only reference with behavioural coverage of all
    complexity factors. Update the adaptive-timeout documentation to match the
    module location and contract.
    
    - In `crates/comenqd/tests/util/mod.rs`, replace
    `uses_all_test_complexity_variants` with an `#[rstest]` test. Add one `#[case]`
    for each factor: `Simple` → 1, `Moderate` → 2 and `Complex` → 3.
    - Use `.with_ci(false).with_coverage(false)` for every configuration to avoid
    environment-dependent results.
    - Use a base timeout within `MIN_TIMEOUT_SECS` and `MAX_TIMEOUT_SECS` for every
    factor in debug and release builds. Use 20 seconds as specified in the follow-up
    prompt; this gives 20–120 seconds.
    - Assert each variant timeout against `factor × Simple timeout`. Keep the
    assertion independent of `DEBUG_MULTIPLIER`.
    - Leave the existing CI, coverage, explicit-flag, stacking and `join_err` tests
    unchanged.
    - In `docs/adaptive-timeouts.md`, replace stale `smart_timeouts` and
    `crate::daemon` references with the helpers' location at
    `crates/comenqd/tests/util/mod.rs`. State that harnesses include the module with
    `mod util;`.
    - Document `Simple` as 1×, `Moderate` as 2× and `Complex` as 3×. Preserve the
    documented constants, retry percentages and environment triggers.
    ===============================================================================
    
    Task: 3
    
    Verify the changes with the CI command set and feature-off checks. Confirm that
    no `dead_code` or `unfulfilled_lint_expectations` diagnostic remains.
    
    - Run `make lint`, `make typecheck` and `make test`. For type checking, use
    `cargo check --workspace --all-targets --all-features` with `-D warnings` if
    using the equivalent command.
    - Without `test-support`, run `RUSTFLAGS="-D warnings" cargo check -p comenqd
    --tests` and `RUSTFLAGS="-D warnings" cargo clippy -p comenqd --all-targets --
    -D warnings`. Check `retry_helper` while `daemon` is compiled out.
    - Run `make fmt` and `make markdownlint`, or equivalent repository checks, for
    the moved file and edited documentation.
    - Compare diagnostics with the baseline from Task 1.1. Report the outcome for
    each target.
    - If the toolchain is unavailable, state this explicitly. Do not report a pass.
    
    💡 Iterate on the plan with: @coderabbitai <feedback>
    Example Feedback
    - @coderabbitai You can skip phase 3. Add a simple unit test case for phase 2.
    - @coderabbitai For design choice 1 go ahead with option 3 and replan.
    

    Start Coding →

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions