Skip to content

Fix example lint findings and inject the environment boundary - #797

Open
leynos wants to merge 1 commit into
harden-lint-app-support-residual-20261022from
harden-lint-examples-20261022
Open

leynos wants to merge 1 commit into
harden-lint-app-support-residual-20261022from
harden-lint-examples-20261022

Conversation

@leynos

@leynos leynos commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Scope

Source remediation for the workspace examples, plus the environment boundary
they need. Nine paths change:

  • examples/packet_enum.rs now reads SERVER_ADDR through mockable's
    Env/DefaultEnv instead of ambient std::env, and the parse is extracted
    into a testable parse_server_addr. Four unit tests cover the missing,
    non-Unicode, configured and malformed cases without mutating the process
    environment.
  • examples/client_echo_login.rs, examples/metadata_routing.rs,
    examples/multi_packet.rs and examples/resp_codec_impl/{codec,encode,parse}.rs
    receive const-ification, distinct shadowed bindings, an error-visible
    detached task, and an explicitly ignored subscriber result.
  • Cargo.toml / Cargo.lock add mockable = "3.0.0" as a dev-dependency
    (ten lockfile lines, no existing version drift).

Position and dependencies

Layer 3 of 5. Stacked on the residual app layer, and the parent of the
self-named-module layer.

Reviewer entrypoints

  • examples/packet_enum.rs — the environment boundary and its tests
  • examples/multi_packet.rs — detached-task error visibility
  • Cargo.toml — one dev-dependency line

Validation evidence (head 0cf5a8c)

This branch was restacked onto origin/main = b194531 on 2026-10-23, after
main moved three commits including #794's toolchain bump from
nightly-2026-03-26 to nightly-2026-10-22. The previous head 53ee29b and its
local gate results belong to the retired toolchain and are not current
evidence.

The weave merge driver was disabled for the replay
(-c core.attributesFile=/dev/null), and the replay was checked against a
driver-free merge-tree result rather than trusted.

Hosted, at this head. The build-test lane ran at this exact commit and
passed every step. It executes the repository's own targets, so its result is
per-layer evidence for the format and lint gates rather than a result inherited
from a neighbour:

Step Target or tool
Format make check-fmt
Lint make lint — rustdoc with -D warnings, Clippy with -D warnings, Whitaker --all
Lint Markdown markdownlint-cli2 over **/*.md
Spelling make spelling
Validate Mermaid diagrams make nixie
Workflow contract tests make test-workflow-contracts
Feature-gate compile checks make test-feature-gate
Test and Measure Coverage cargo llvm-cov nextest --workspace, default features and targets

https://github.com/leynos/wireframe/actions/runs/39959682710/job/120434229692

The instrumented run executed 1207 tests, 1207 passed, 0 skipped and
reported 87.92% against the committed 87.8% baseline, so the ratchet passed.
Read from the job log, not inferred from the job conclusion.

That run is narrower than the Make targets — no --all-targets, no
--all-features, no doctests — which is why the local runs below are still
required.

Local. Run sequentially at this exact head with make:

Known baseline failures

None observed at this head.

Deferred work

Remaining source census findings, final lint-configuration adoption, the
testkit argument-count decision and Whitaker --workspace coverage.

🤖 Generated with Claude Code

Summary by Sourcery

Harden workspace examples by introducing an injectable environment boundary, improving error visibility, and resolving remaining lint findings.

New Features:

  • Add environment-aware server address configuration to the packet enum example with isolated coverage for default, valid, and invalid values.

Bug Fixes:

  • Preserve detached task failures and make malformed server address configuration report clear input errors.

Enhancements:

  • Clean up example lint findings through clearer bindings, explicit ignored results, and compile-time evaluable helpers.

Build:

  • Add mockable as a development dependency.

Tests:

  • Add unit tests for packet enum server address parsing without modifying the process environment.

References

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in 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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Team
  • Run ID: 870c5098-828e-4492-9a6b-52bc3f7619b3
Commits

Reviewing files that changed from the base of the PR and between 13d33c7 and 0cf5a8c.

Files ignored due to path filters: 1
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 8
  • Cargo.toml
  • examples/client_echo_login.rs
  • examples/metadata_routing.rs
  • examples/multi_packet.rs
  • examples/packet_enum.rs
  • examples/resp_codec_impl/codec.rs
  • examples/resp_codec_impl/encode.rs
  • examples/resp_codec_impl/parse.rs
🔗 Linked repositories identified

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

Included review availability: This review used your included allowance. 2 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.

Summary

Add mockable as a development dependency. Use mockable::Env and DefaultEnv in examples/packet_enum.rs to retrieve SERVER_ADDR, and test the parsing behaviour for missing, non-Unicode, valid, and malformed values without changing the process environment.

Address lint findings in the examples. Mark eligible RESP codec functions const, clarify shadowed bindings, retain tracing initialisation results, and report detached-task join failures.

Validation

The supplied PR notes report that the hosted build-test lane passed, with 1,207 tests passing and no skips. The run did not use --all-targets or --all-features, and it did not run doctests.

Walkthrough

The pull request adds mockable environment access and tests to packet_enum, logs a chunk-task join failure in multi_packet, and adjusts example bindings. It also makes selected RESP codec constructors and helpers const fn, and renames parsed length variables without changing parsing limits or errors.

Changes

Packet example environment lookup

Layer / File(s) Summary
Environment lookup and address parsing
Cargo.toml, examples/packet_enum.rs
packet_enum uses the mockable environment interface and passes the SERVER_ADDR lookup result to its parser. Lookup errors use DEFAULT_ADDR; malformed configured addresses return InvalidInput. Tests cover missing and non-Unicode values, valid addresses, and malformed input.

Example task and tracing updates

Layer / File(s) Summary
Task results and tracing bindings
examples/client_echo_login.rs, examples/metadata_routing.rs, examples/multi_packet.rs
The examples bind tracing initialisation results and retain the prepared application in a named variable. The summary task logs a chunk-task join error and continues to send the summary.

RESP codec const functions and parser names

Layer / File(s) Summary
Codec constructors and parsing helpers
examples/resp_codec_impl/codec.rs, examples/resp_codec_impl/encode.rs, examples/resp_codec_impl/parse.rs
Selected constructors and helpers are now const fn. The parser uses named bulk payload and array element counts. Parsing limits and errors remain unchanged.

Suggested reviewers: codescene-access

Priority: Low

Change: Refactor

Merge Risk: Minimal · up to 0cf5a

No concrete issue remains that needs resolution before merging; proceed with normal checks.

Caution

Pre-merge checks failed

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

  • Ignore

Failed Failed checks: 2 errors · 2 warnings

Check name Status Explanation Resolution
Testing (Overall) Error The new address parsing behaviour has substantive tests in examples/packet_enum.rs:144-179, covering missing, non-Unicode, valid and malformed values. However, the pull request also changes detached… Add a deterministic test for the multi-packet failure path. Inject or otherwise trigger a failing chunk task, capture the local tracing output, and assert that chunk producer failed and the join error are emitted. Keep the test failing wh…
Testing (Unit And Behavioural) Error The new tests cover meaningful default, non-Unicode, valid, and malformed values, but they only call the private parse_server_addr helper (examples/packet_enum.rs:154-179). The changed example wor… Add a behavioural or end-to-end test for packet_enum that exercises the injected environment lookup through the server setup and verifies the selected listener address. Cover the fallback address, a configured valid address, and malformed…
Developer Documentation Warning The pull request adds the mockable = "3.0.0" development dependency in Cargo.toml:78 and introduces an injectable environment boundary in examples/packet_enum.rs through mockable::Env and `Def… Update docs/developers-guide.md with the new development requirement and boundary. Document mockable = "3.0.0", the use of Env/DefaultEnv at the environment edge, pure parsing helpers that accept lookup results, and tests that avoid…
Testing (Compile-Time / Ui) Warning The pull request introduces compile-time behaviour through pub const fn RespFrameCodec::new and several const fn helpers in examples/resp_codec_impl/{codec,encode,parse}.rs. The existing tests c… Add a trybuild pass fixture and register it in the existing compile-time harness. Exercise RespFrameCodec::new in a const context, and cover the changed const helpers where their visibility permits. Keep assertions focused on successful c…
Passed Passed checks: 11 passed
Check name Status Explanation
Title check Passed The title accurately describes the two main changes: resolving example lint findings and adding an environment boundary. No roadmap or issue number is required because the description does not identif…
Description check Passed The description directly explains the environment boundary, lint remediation, dependency change, tests, validation evidence, and PR dependencies.
Docstring Coverage Passed Docstring coverage is 80.95% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 7 files. (1 skipped: 1 …
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 this check. The pull request changes only example sources and test-only dependency metadata; it does not add or change library functionality. packet_enum preserves the existing SERVER_ADDR fa…
Module-Level Documentation Passed PASS. Every changed top-level Rust module has module documentation explaining its purpose. The new packet_enum::tests module also has an inner docstring at examples/packet_enum.rs:144-146. The und…
Testing (Property / Proof) Passed No property-test requirement is introduced. The behavioural change in examples/packet_enum.rs has a small, auditable contract: both VarError variants use DEFAULT_ADDR, a valid configured address…
Unit Architecture Passed No Unit Architecture failure is introduced. examples/packet_enum.rs:109-116 keeps address parsing as a pure function with an explicit input and std::io::Result output. run performs the environme…
Domain Architecture Passed Pass. Keep the environment lookup at the server setup boundary: run calls DefaultEnv.raw("SERVER_ADDR") and passes the result to parse_server_addr (examples/packet_enum.rs:119-125). The parser o…
Observability Passed Pass the observability check. The change makes the detached chunk producer failure visible at its async task boundary with an error log and the stable operation context chunk producer failed (`examp…
Full details: Title check

Explanation

The title accurately describes the two main changes: resolving example lint findings and adding an environment boundary. No roadmap or issue number is required because the description does not identify an issue or roadmap item that this PR implements.

Full details: Docstring Coverage

Explanation

Docstring coverage is 80.95% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 7 files. (1 skipped: 1 unsupported.)

Full details: User-Facing Documentation

Explanation

Pass this check. The pull request changes only example sources and test-only dependency metadata; it does not add or change library functionality. packet_enum preserves the existing SERVER_ADDR fallback and validation behaviour, while the other edits are lint, const, binding, and example logging changes. No update to docs/users-guide.md is required.

Full details: Module-Level Documentation

Explanation

PASS. Every changed top-level Rust module has module documentation explaining its purpose. The new packet_enum::tests module also has an inner docstring at examples/packet_enum.rs:144-146. The undocumented tests modules in examples/resp_codec_impl/codec.rs and encode.rs pre-date this pull request and were not changed, so they do not create a pull-request-caused failure.

Full details: Testing (Property / Proof)

Explanation

No property-test requirement is introduced. The behavioural change in examples/packet_enum.rs has a small, auditable contract: both VarError variants use DEFAULT_ADDR, a valid configured address parses, and malformed input returns InvalidInput; the added rstest and unit tests cover these branches. The remaining changes are const qualification, binding renames, and explicit task/result handling, with no new broad input or state invariant. Existing parser property tests are unchanged.

Full details: Unit Architecture

Explanation

No Unit Architecture failure is introduced. examples/packet_enum.rs:109-116 keeps address parsing as a pure function with an explicit input and std::io::Result output. run performs the environment query at the composition boundary through DefaultEnv.raw("SERVER_ADDR") and propagates lookup/parsing failure at examples/packet_enum.rs:119-125. Tests supply Ok and both VarError cases directly, without mutating process state (examples/packet_enum.rs:144-179). The remaining changes only clarify bindings, make pure helpers const, and log an existing detached-task failure; they do not add hidden dependencies or unrelated responsibilities.

Full details: Domain Architecture

Explanation

Pass. Keep the environment lookup at the server setup boundary: run calls DefaultEnv.raw("SERVER_ADDR") and passes the result to parse_server_addr (examples/packet_enum.rs:119-125). The parser only converts the supplied value into a SocketAddr and applies the fallback (lines 108-117), so it does not access process environment state. The changed files do not add infrastructure dependencies to domain logic or alter a domain model boundary. The tests exercise the parser with explicit results (lines 144-180), which keeps the parsing logic independent of ambient environment state.

Full details: Observability

Explanation

Pass the observability check. The change makes the detached chunk producer failure visible at its async task boundary with an error log and the stable operation context chunk producer failed (examples/multi_packet.rs:96-104). The SERVER_ADDR change preserves the existing default and malformed-input behaviour while adding isolated tests; it does not add a new production failure mode (examples/packet_enum.rs:108-125, 144-180). The remaining edits are lint-oriented or binding renames and do not require new metrics, alerts, or tracing.

Full details: Testing (Overall)

Explanation

The new address parsing behaviour has substantive tests in examples/packet_enum.rs:144-179, covering missing, non-Unicode, valid and malformed values. However, the pull request also changes detached-task error handling in examples/multi_packet.rs:96-100 by logging a JoinError instead of discarding it. No test exercises this path; repository search found no test for multi_packet_response or chunk producer failed. The implementation could revert to ignoring the join result and the tests would still pass.

Resolution

Add a deterministic test for the multi-packet failure path. Inject or otherwise trigger a failing chunk task, capture the local tracing output, and assert that chunk producer failed and the join error are emitted. Keep the test failing when the join result is discarded.

Full details: Testing (Unit And Behavioural)

Explanation

The new tests cover meaningful default, non-Unicode, valid, and malformed values, but they only call the private parse_server_addr helper (examples/packet_enum.rs:154-179). The changed example workflow reads SERVER_ADDR and binds WireframeServer in run (examples/packet_enum.rs:119-134). No test exercises that environment-to-bind boundary. The repository's TCP tests cover generic server behaviour, not this example wiring.

Resolution

Add a behavioural or end-to-end test for packet_enum that exercises the injected environment lookup through the server setup and verifies the selected listener address. Cover the fallback address, a configured valid address, and malformed configuration at that boundary. Keep the existing helper unit tests for parser-specific error details.

Full details: Developer Documentation

Explanation

The pull request adds the mockable = "3.0.0" development dependency in Cargo.toml:78 and introduces an injectable environment boundary in examples/packet_enum.rs through mockable::Env and DefaultEnv.raw. These are new development requirements and an internal testing abstraction. The pull request changes no file under docs/, and docs/developers-guide.md does not document mockable, the environment boundary, or its testing convention. The separate dependency-injection document does not satisfy the explicit developer's-guide requirement.

Resolution

Update docs/developers-guide.md with the new development requirement and boundary. Document mockable = "3.0.0", the use of Env/DefaultEnv at the environment edge, pure parsing helpers that accept lookup results, and tests that avoid mutating the process environment. Link the existing dependency-injection document if it remains normative, and record any related architectural decision in the relevant design document or ADR.

Full details: Testing (Compile-Time / Ui)

Explanation

The pull request introduces compile-time behaviour through pub const fn RespFrameCodec::new and several const fn helpers in examples/resp_codec_impl/{codec,encode,parse}.rs. The existing tests call these functions at runtime only; they do not prove const-context use. The repository already uses trybuild in tests/compile_error.rs, but the pull request adds no compile-time fixture or harness entry. The changed examples add no snapshot tests. The changed logging and parser error text do not establish a separate stable snapshot contract, so a focused snapshot is not required for this change.

Resolution

Add a trybuild pass fixture and register it in the existing compile-time harness. Exercise RespFrameCodec::new in a const context, and cover the changed const helpers where their visibility permits. Keep assertions focused on successful const evaluation. Retain the existing semantic error assertion for SERVER_ADDR; add a snapshot only if the example log or structured output becomes an intended stable contract.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Set SERVER_ADDR where addresses roam,
Let codec helpers count at compile time.
Log the task that could not join,
Keep each example’s bindings clear.
Send the final summary on its way.

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

@sourcery-ai

sourcery-ai Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

The PR remediates lint findings across workspace examples while introducing a mockable environment boundary for SERVER_ADDR parsing, adding isolated coverage for its fallback and validation behavior, and making selected RESP helpers const-evaluable.

Sequence diagram for injected SERVER_ADDR parsing

sequenceDiagram
    participant Run as run
    participant Env as DefaultEnv
    participant Parser as parse_server_addr
    participant Server as WireframeServer

    Run->>Env: raw(SERVER_ADDR)
    Env-->>Run: Result<String, VarError>
    Run->>Parser: parse_server_addr(address_result)
    alt lookup fails
        Parser-->>Run: DEFAULT_ADDR
    else configured address
        Parser-->>Run: parsed SocketAddr
    else malformed address
        Parser-->>Run: InvalidInput error
    end
    Run->>Server: bind(socket_addr)
Loading

File-Level Changes

Change Details Files
Inject environment access into the packet example and make address parsing independently testable.
  • Replace ambient environment reads with mockable's DefaultEnv boundary.
  • Parse injected lookup results with the existing default and validation behavior.
  • Add four unit tests for missing, non-Unicode, valid, and malformed values without changing process state.
examples/packet_enum.rs
Cargo.toml
Cargo.lock
Improve example lint compliance and error visibility in asynchronous and tracing code.
  • Retain subscriber initialization results in named underscore bindings.
  • Report detached chunk-task failures instead of silently discarding them.
  • Rename shadowed bindings to clarify prepared application and parser count/length values.
examples/client_echo_login.rs
examples/metadata_routing.rs
examples/multi_packet.rs
examples/resp_codec_impl/parse.rs
Expand compile-time evaluation opportunities in RESP codec helpers.
  • Mark constructors and numeric digit-counting helpers as const.
  • Make parser context construction const.
examples/resp_codec_impl/codec.rs
examples/resp_codec_impl/encode.rs
examples/resp_codec_impl/parse.rs

Possibly linked issues

  • #unknown: The PR directly implements the issue’s packet_enum environment seam and tests, while deferring broader enforcement and documentation.

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 added this pull request to stack #802 October 23, 2026 11:32
Replace suppressed or silent conversions in the RESP and metadata examples
with explicit, fallible forms, mark eligible example constructors `const`,
and give the detached summary task a visible error path.

`packet_enum` read `SERVER_ADDR` directly with `std::env::var` and mapped a
missing value through `unwrap_or_else`. It now accepts the lookup result and
reads it through `mockable::DefaultEnv`, so the environment is an injected
boundary rather than ambient process access. Coverage for missing,
non-Unicode, valid, and malformed values runs without mutating the
environment. The new `mockable` dev-dependency is the only lockfile change.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@leynos
leynos force-pushed the harden-lint-examples-20261022 branch from 53ee29b to 0cf5a8c Compare October 23, 2026 13:15
@leynos
leynos marked this pull request as ready for review October 24, 2026 05:26
@sourcery-ai

sourcery-ai Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Sorry @leynos, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 5 days and 15 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T05:27:01.503545Z 0cf5a8c Draft marked ready
🔒 Security Review ✅ Completed 2026-10-24T05:27:37.365030Z 0cf5a8c Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Pre-merge checks failed. Please resolve the failing checks before merging.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant