Add cargo audit to CI#200
Conversation
Add a Corbusier-style `make audit` target that walks Rust manifests and runs `cargo audit` for each one. Install `cargo-audit` in CI and include the audit job in the test roll-up. Upgrade the vulnerable dependency paths found by the new target, including Wasmtime, libSQL, Bollard, testcontainers, and AWS Bedrock SDK feature selection. Keep the remaining libSQL Rustls/WebPKI advisory ignores centralised until upstream moves off the older TLS stack.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Reviewer's GuideAdds a Rust dependency audit gate to CI using cargo-audit, centralizes audit ignores, and upgrades key Rust dependencies (wasmtime, bollard, libsql, AWS SDK, testcontainers) along with the necessary code adaptations in WASM tooling and Docker orchestration to satisfy the new audit and dependency APIs. Flow diagram for new cargo-audit CI gateflowchart TD
A[GitHub_Actions_test_workflow] --> B[Install_cargo-audit]
B --> C[Run_make_audit]
C --> D[rust-audit_Makefile_target]
D --> E[find_Cargo.toml_manifests]
E --> F[Per_manifest: cd_manifest_dir]
F --> G[Run_CARGO_AUDIT_with_AUDIT_FLAGS]
G --> H[Fail_or_pass_CI_based_on_cargo-audit_result]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
@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. Comment on file use wasmtime::Store;
use wasmtime::component::Linker;
use wasmtime_wasi::{ResourceTable, WasiCtx, WasiCtxBuilder, WasiView};
use wasmtime::component::{HasSelf, Linker};❌ New issue: Low Cohesion |
This comment was marked as resolved.
This comment was marked as resolved.
|
@coderabbitai Please suggest a fix for the the underlying issues in the codebase resulting in the following audit violations and provide an AI coding agent prompt for the fix: |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
@coderabbitai please add a tracking issue to ultimately replace serde_norway with serdy_saphyr |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 45
|
Move the WASM channel wrapper's host store, conversion helpers, credential resolution, and attachment helpers into focused child modules. Keep the generated WIT bindings and public wrapper API in `mod.rs` so callers can continue to use `crate::channels::wasm::wrapper::*`.
Swap the direct `serde_yml` dependency for `serde_yaml` so cargo audit no longer reports the unmaintained `serde_yml` and `libyml` advisories. Add a central temporary audit ignore for the unpublished Wasmtime WASI `path_open(TRUNCATE)` fix so the audit gate remains actionable until the upstream patch release is available on crates.io.
|
@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. Low Cohesionsrc/channels/wasm/wrapper/mod.rs: What lead to degradation?This module has at least 23 different responsibilities amongst its 43 functions, threshold = 3 Why does this problem occur?Cohesion is a measure of how well the elements in a file belong together. CodeScene measures cohesion using the LCOM4 metric (Lack of Cohesion Measure). With LCOM4, the functions inside a module are related if a) they access the same data members, or b) they call each other. High Cohesion is desirable as it means that all functions are related and likely to represent the same responsibility. Low Cohesion is problematic since it means that the module contains multiple behaviors. Low Cohesion leads to code that's harder to understand, requires more tests, and very often become a coordination magnet for developers. How to fix it?Look to modularize the code by splitting the file into more cohesive units; functions that belong together should still be located together. A common refactoring is EXTRACT CLASS. Helpful refactoring examplesTo 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# low_cohesion_example.js
var userLayer = connectUsers(myConnectionProperties);
-var chessEngine = startEngine(gameProperties);
+// [Refactoring: moved the data related to chess to a new chessGame.js module]
+// The module contains login related functionality that forms one behaviour: all
+// code is related since it either a) uses the same data, or b) calls the same functions.
export function login(newUser) {
val authenticated = userLayer.authenticate(newUser);
traceLoginFor(authenticated);
// ...some code...
}
-// playChess seems like a very unrelated responsibility.
-// Should it really be within the same module?
-
-export function playChess(loggedInUser) {
- var board = chessEngine.newBoard();
-
- return newGameOn(board, loggedInUser);
-}
+// [Refactoring: moved playChess to a new chessGame.js module
+// As a result of this refactoring, the module maintains a
+// single behavior where all code and data is related: high cohesion.] |
|
@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. String Heavy Function Argumentssrc/channels/wasm/wrapper/store.rs: What lead to degradation?In this module, 47.4% of all arguments to its 14 functions are strings. The threshold for string arguments is 39.0% Why does this problem occur?String is a generic type that fail to capture the constraints of the domain object it represents. In this module, 47 % of all function arguments are string types. How to fix it?Heavy string usage indicates a missing domain language. Introduce data types that encapsulate the semantics. For example, a user_name is better represented as a constrained User type rather than a pure string, which could be anything. |
|
@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. Complex Methodsrc/channels/wasm/wrapper/convert.rs: status_to_wit What lead to degradation?status_to_wit has a cyclomatic complexity of 11, threshold = 9 Why does this problem occur?A Complex Method has a high cyclomatic complexity. The recommended threshold for the Rust language is a cyclomatic complexity lower than 9. How to fix it?There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using EXTRACT FUNCTION. Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the DECOMPOSE CONDITIONAL refactoring. Helpful refactoring examplesThis code health issue has been solved before in this project. Here are some examples for inspiration: undefined# wit_compat.rs (8a29e56)
-use std::path::{Path, PathBuf};
+use std::path::PathBuf;
-/// Search paths for WASM artifacts produced by cargo-component.
-fn find_wasm_artifact(source_dir: &Path, crate_name: &str) -> Option<PathBuf> {
- let artifact_name = crate_name.replace('-', "_");
-
- // Crate-local target dir (CI, default cargo)
- for target_triple in &["wasm32-wasip2", "wasm32-wasip1", "wasm32-wasi"] {
- let candidate = source_dir
- .join("target")
- .join(target_triple)
- .join("release")
- .join(format!("{artifact_name}.wasm"));
- if candidate.exists() {
- return Some(candidate);
- }
- }
-
- // Shared target dir (CARGO_TARGET_DIR env)
- if let Ok(shared) = std::env::var("CARGO_TARGET_DIR") {
- for target_triple in &["wasm32-wasip2", "wasm32-wasip1", "wasm32-wasi"] {
- let candidate = Path::new(&shared)
- .join(target_triple)
- .join("release")
- .join(format!("{artifact_name}.wasm"));
- if candidate.exists() {
- return Some(candidate);
- }
- }
- }
-
- // Common shared target location (~/.cargo/shared-target)
- if let Some(home) = dirs::home_dir() {
- let shared = home.join(".cargo/shared-target");
- if shared.exists() {
- for target_triple in &["wasm32-wasip2", "wasm32-wasip1", "wasm32-wasi"] {
- let candidate = shared
- .join(target_triple)
- .join("release")
- .join(format!("{artifact_name}.wasm"));
- if candidate.exists() {
- return Some(candidate);
- }
- }
- }
- }
-
- None
-}
-
/// Parse registry manifests to discover all WASM extensions.
for ext in &tool_extensions {
- let wasm_path = match find_wasm_artifact(&ext.source_dir, &ext.crate_name) {
+ let wasm_path = match ironclaw::registry::artifacts::find_wasm_artifact(
+ &ext.source_dir,
+ &ext.crate_name,
+ "release",
+ ) {
Some(p) => p,
for ext in &channel_extensions {
- let wasm_path = match find_wasm_artifact(&ext.source_dir, &ext.crate_name) {
+ let wasm_path = match ironclaw::registry::artifacts::find_wasm_artifact(
+ &ext.source_dir,
+ &ext.crate_name,
+ "release",
+ ) {
Some(p) => p, |
|
@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. Excess Number of Function Argumentssrc/channels/wasm/wrapper/store.rs: near.http_request What lead to degradation?near.http_request has 6 arguments, max arguments = 4 Why does this problem occur?Functions with many arguments indicate either a) low cohesion where the function has too many responsibilities, or b) a missing abstraction that encapsulates those arguments. How to fix it?Start by investigating the responsibilities of the function. Make sure it doesn't do too many things, in which case it should be split into smaller and more cohesive functions. Consider the refactoring INTRODUCE PARAMETER OBJECT to encapsulate arguments that refer to the same logical concept. |
Move the large wrapper test module into focused child modules for approval, attachments, channel behaviour, cloning, conversion, dispatch, and store coverage. Keep the existing test bodies and expectations while reducing the cohesion burden on a single test file.
Move placeholder replacement, unresolved-placeholder warnings, and redaction replacement into focused helpers in the WASM channel store. Keep the public store methods and logging behaviour unchanged while reducing their branch-heavy bodies.
|
@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. Complex Methodsrc/channels/wasm/wrapper/dispatch.rs: WasmChannel.process_emitted_messages, WasmChannel.dispatch_emitted_messages What lead to degradation?WasmChannel.process_emitted_messages has a cyclomatic complexity of 10, threshold = 9 Why does this problem occur?A Complex Method has a high cyclomatic complexity. The recommended threshold for the Rust language is a cyclomatic complexity lower than 9. How to fix it?There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using EXTRACT FUNCTION. Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the DECOMPOSE CONDITIONAL refactoring. Helpful refactoring examplesThis code health issue has been solved before in this project. Here are some examples for inspiration: undefined# wit_compat.rs (8a29e56)
-use std::path::{Path, PathBuf};
+use std::path::PathBuf;
-/// Search paths for WASM artifacts produced by cargo-component.
-fn find_wasm_artifact(source_dir: &Path, crate_name: &str) -> Option<PathBuf> {
- let artifact_name = crate_name.replace('-', "_");
-
- // Crate-local target dir (CI, default cargo)
- for target_triple in &["wasm32-wasip2", "wasm32-wasip1", "wasm32-wasi"] {
- let candidate = source_dir
- .join("target")
- .join(target_triple)
- .join("release")
- .join(format!("{artifact_name}.wasm"));
- if candidate.exists() {
- return Some(candidate);
- }
- }
-
- // Shared target dir (CARGO_TARGET_DIR env)
- if let Ok(shared) = std::env::var("CARGO_TARGET_DIR") {
- for target_triple in &["wasm32-wasip2", "wasm32-wasip1", "wasm32-wasi"] {
- let candidate = Path::new(&shared)
- .join(target_triple)
- .join("release")
- .join(format!("{artifact_name}.wasm"));
- if candidate.exists() {
- return Some(candidate);
- }
- }
- }
-
- // Common shared target location (~/.cargo/shared-target)
- if let Some(home) = dirs::home_dir() {
- let shared = home.join(".cargo/shared-target");
- if shared.exists() {
- for target_triple in &["wasm32-wasip2", "wasm32-wasip1", "wasm32-wasi"] {
- let candidate = shared
- .join(target_triple)
- .join("release")
- .join(format!("{artifact_name}.wasm"));
- if candidate.exists() {
- return Some(candidate);
- }
- }
- }
- }
-
- None
-}
-
/// Parse registry manifests to discover all WASM extensions.
for ext in &tool_extensions {
- let wasm_path = match find_wasm_artifact(&ext.source_dir, &ext.crate_name) {
+ let wasm_path = match ironclaw::registry::artifacts::find_wasm_artifact(
+ &ext.source_dir,
+ &ext.crate_name,
+ "release",
+ ) {
Some(p) => p,
for ext in &channel_extensions {
- let wasm_path = match find_wasm_artifact(&ext.source_dir, &ext.crate_name) {
+ let wasm_path = match ironclaw::registry::artifacts::find_wasm_artifact(
+ &ext.source_dir,
+ &ext.crate_name,
+ "release",
+ ) {
Some(p) => p,Excess Number of Function Argumentssrc/channels/wasm/wrapper/dispatch.rs: WasmChannel.dispatch_emitted_messages What lead to degradation?WasmChannel.dispatch_emitted_messages has 6 arguments, max arguments = 4 Why does this problem occur?Functions with many arguments indicate either a) low cohesion where the function has too many responsibilities, or b) a missing abstraction that encapsulates those arguments. How to fix it?Start by investigating the responsibilities of the function. Make sure it doesn't do too many things, in which case it should be split into smaller and more cohesive functions. Consider the refactoring INTRODUCE PARAMETER OBJECT to encapsulate arguments that refer to the same logical concept. |
|
@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response. Large Methodsrc/channels/wasm/wrapper/tests/dispatch.rs: test_dispatch_emitted_messages_preserves_attachments What lead to degradation?test_dispatch_emitted_messages_preserves_attachments has 70 lines, threshold = 70 Why does this problem occur?Overly long functions make the code harder to read. The recommended maximum function length for the Rust language is 70 lines of code. Severity: Brain Method - Complex Method - Long Method. How to fix it?We recommend to be careful here -- just splitting long functions don't necessarily make the code easier to read. Instead, look for natural chunks inside the functions that expresses a specific task or concern. Often, such concerns are indicated by a Code Comment followed by an if-statement. Use the EXTRACT FUNCTION refactoring to encapsulate that concern. Excess Number of Function Argumentssrc/channels/wasm/wrapper/tests/dispatch.rs: assert_attachment What lead to degradation?assert_attachment has 8 arguments, max arguments = 4 Why does this problem occur?Functions with many arguments indicate either a) low cohesion where the function has too many responsibilities, or b) a missing abstraction that encapsulates those arguments. How to fix it?Start by investigating the responsibilities of the function. Make sure it doesn't do too many things, in which case it should be split into smaller and more cohesive functions. Consider the refactoring INTRODUCE PARAMETER OBJECT to encapsulate arguments that refer to the same logical concept. |
|
@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. Code Duplicationsrc/channels/wasm/wrapper/tests/channel.rs: What lead to degradation?The module contains 4 functions with similar structure: test_typing_task_cancelled_on_approval_needed,test_typing_task_cancelled_on_awaiting_approval_status,test_typing_task_cancelled_on_done,test_typing_task_persists_on_tool_started Why does this problem occur?Duplicated code often leads to code that's harder to change since the same logical change has to be done in multiple functions. More duplication gives lower code health. How to fix it?A certain degree of duplicated code might be acceptable. The problems start when it is the same behavior that is duplicated across the functions in the module, ie. a violation of the Don't Repeat Yourself (DRY) principle. DRY violations lead to code that is changed together in predictable patterns, which is both expensive and risky. DRY violations can be identified using CodeScene's X-Ray analysis to detect clusters of change coupled functions with high code similarity. Read More Code Duplicationsrc/channels/wasm/wrapper/tests/convert.rs: What lead to degradation?The module contains 13 functions with similar structure: test_status_to_wit_auth_completed_failure,test_status_to_wit_auth_completed_success,test_status_to_wit_done,test_status_to_wit_done_case_insensitive and 9 more functions Why does this problem occur?Duplicated code often leads to code that's harder to change since the same logical change has to be done in multiple functions. More duplication gives lower code health. How to fix it?A certain degree of duplicated code might be acceptable. The problems start when it is the same behavior that is duplicated across the functions in the module, ie. a violation of the Don't Repeat Yourself (DRY) principle. DRY violations lead to code that is changed together in predictable patterns, which is both expensive and risky. DRY violations can be identified using CodeScene's X-Ray analysis to detect clusters of change coupled functions with high code similarity. Read More |
|
@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. Code Duplicationchannels-src/telegram/src/lib.rs: What lead to degradation?introduced similar code in: audio_attachment,document_attachment,photo_attachment,sticker_attachment and 2 more functions Why does this problem occur?Duplicated code often leads to code that's harder to change since the same logical change has to be done in multiple functions. More duplication gives lower code health. How to fix it?A certain degree of duplicated code might be acceptable. The problems start when it is the same behavior that is duplicated across the functions in the module, ie. a violation of the Don't Repeat Yourself (DRY) principle. DRY violations lead to code that is changed together in predictable patterns, which is both expensive and risky. DRY violations can be identified using CodeScene's X-Ray analysis to detect clusters of change coupled functions with high code similarity. Read More |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
@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. Bumpy Road Aheadsrc/channels/wasm/wrapper/store.rs: ChannelStoreData.redact_credentials What lead to degradation?ChannelStoreData.redact_credentials has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is 2 blocks per function Why does this problem occur?A Bumpy Road is a function that contains multiple chunks of nested conditional logic inside the same function. The deeper the nesting and the more bumps, the lower the code health. How to fix it?Bumpy Road implementations indicate a lack of encapsulation. Check out the detailed description of the Bumpy Road code health issue. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Update the WIT package versions and matching runtime constants after the interface changes in this branch. Bump each published tool and channel registry entry whose extension source changed so the version-bump CI check can enforce compatibility metadata.
Introduce a dispatch context parameter object for polling callbacks and share emitted-message conversion plus rate-limited sending between the two WASM channel dispatch paths. Keep the internal process API intact while reducing complexity and argument count in the dispatch module.
Replace the broad attachment assertion helper with an expected-value parameter object and move repeated attachment fixture construction into a single helper. Keep the dispatch test expectations unchanged while removing the local Clippy argument-count suppression.
Introduce a media specification parameter object for Telegram attachments and route each per-media helper through one common attachment constructor. Keep the existing MIME defaults, filename handling, and duration mapping unchanged while removing the repeated constructor pattern.
Add shared helpers for typing-task lifecycle assertions and WIT status conversion setup in the WASM wrapper tests. Keep the existing test coverage and assertions while removing repeated setup code from the channel and convert test modules.
Move the empty-secret guards in `redact_credentials` into iterator filters so the loop bodies stay unconditional. Keep the redaction behaviour unchanged while removing the remaining nested conditional blocks from the method.
There was a problem hiding this comment.
Code Health Improved
(7 files improve in Code Health)
Gates Failed
New code is healthy
(3 new files with code health below 10.00)
Enforce critical code health rules
(1 file with Bumpy Road Ahead)
Enforce advisory code health rules
(5 files with Large Method, Complex Method, Code Duplication)
Gates Passed
3 Quality Gates Passed
See analysis details in CodeScene
Reason for failure
| New code is healthy | Violations | Code Health Impact | |
|---|---|---|---|
| status.rs | 2 rules | 9.00 | Suppress |
| convert.rs | 1 rule | 9.10 | Suppress |
| convert.rs | 1 rule | 9.57 | Suppress |
| Enforce critical code health rules | Violations | Code Health Impact | |
|---|---|---|---|
| status.rs | 1 critical rule | 9.00 | Suppress |
| Enforce advisory code health rules | Violations | Code Health Impact | |
|---|---|---|---|
| status.rs | 1 advisory rule | 9.00 | Suppress |
| convert.rs | 1 advisory rule | 9.10 | Suppress |
| convert.rs | 1 advisory rule | 9.57 | Suppress |
| lib.rs | 1 advisory rule | 8.86 → 8.84 | Suppress |
| lib.rs | 1 advisory rule | 3.03 → 3.29 | Suppress |
View Improvements
| File | Code Health Impact | Categories Improved |
|---|---|---|
| wrapper.rs | 5.73 → 6.07 | Low Cohesion, Complex Method, Excess Number of Function Arguments |
| metadata.rs | 9.69 → 10.00 | Excess Number of Function Arguments |
| mod.rs | 4.30 → 8.11 | Lines of Code in a Single File, Complex Method, Bumpy Road Ahead, Excess Number of Function Arguments, Code Duplication, Large Assertion Blocks |
| lib.rs | 8.44 → 8.57 | Bumpy Road Ahead |
| lib.rs | 3.03 → 3.29 | Complex Method, Large Method, Bumpy Road Ahead, Overall Code Complexity, Deep, Nested Complexity |
| lib.rs | 6.84 → 6.94 | Bumpy Road Ahead, Code Duplication |
| setup.rs | 9.36 → 10.00 | Large Method |
Quality Gate Profile: Pay Down Tech Debt
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.
|
@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response. Large Methodsrc/channels/wasm/wrapper/tests/dispatch.rs: test_dispatch_emitted_messages_preserves_attachments What lead to degradation?test_dispatch_emitted_messages_preserves_attachments has 70 lines, threshold = 70 Why does this problem occur?Overly long functions make the code harder to read. The recommended maximum function length for the Rust language is 70 lines of code. Severity: Brain Method - Complex Method - Long Method. How to fix it?We recommend to be careful here -- just splitting long functions don't necessarily make the code easier to read. Instead, look for natural chunks inside the functions that expresses a specific task or concern. Often, such concerns are indicated by a Code Comment followed by an if-statement. Use the EXTRACT FUNCTION refactoring to encapsulate that concern. Excess Number of Function Argumentssrc/channels/wasm/wrapper/tests/dispatch.rs: assert_attachment What lead to degradation?assert_attachment has 8 arguments, max arguments = 4 Why does this problem occur?Functions with many arguments indicate either a) low cohesion where the function has too many responsibilities, or b) a missing abstraction that encapsulates those arguments. How to fix it?Start by investigating the responsibilities of the function. Make sure it doesn't do too many things, in which case it should be split into smaller and more cohesive functions. Consider the refactoring INTRODUCE PARAMETER OBJECT to encapsulate arguments that refer to the same logical concept. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== src/channels/wasm/wrapper/tests/dispatch.rs ==="
cat src/channels/wasm/wrapper/tests/dispatch.rs 2>/dev/null || {
echo "File not found"
fd -a 'dispatch.rs' .
}
echo
echo "=== Relevant symbols ==="
rg -n -C 5 'fn assert_attachment|test_dispatch_emitted_messages_preserves_attachments|struct ExpectedAttachment|build_test_attachments|dispatch_emitted_messages' src/channels/wasm/wrapper/tests/dispatch.rs 2>/dev/null || trueLength of output: 12928
File: FixKeep the existing fn assert_attachment(
attachment: &crate::channels::IncomingAttachment,
expected: &ExpectedAttachment<'_>,
)Treat that part of the CodeScene report as stale. Address the remaining Large Method issue by extracting the repeated dispatch-test setup and the attachment verification block:
This reduces the test body well below the 70-line threshold and preserves the named parameter object that already fixed the excessive argument count. AI coding-agent prompt |
|
@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. Complex Methodsrc/channels/wasm/wrapper/dispatch.rs: WasmChannel.process_emitted_messages, WasmChannel.dispatch_emitted_messages What lead to degradation?WasmChannel.process_emitted_messages has a cyclomatic complexity of 10, threshold = 9 Why does this problem occur?A Complex Method has a high cyclomatic complexity. The recommended threshold for the Rust language is a cyclomatic complexity lower than 9. How to fix it?There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using EXTRACT FUNCTION. Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the DECOMPOSE CONDITIONAL refactoring. Helpful refactoring examplesThis code health issue has been solved before in this project. Here are some examples for inspiration: undefined# wit_compat.rs (8a29e56)
-use std::path::{Path, PathBuf};
+use std::path::PathBuf;
-/// Search paths for WASM artifacts produced by cargo-component.
-fn find_wasm_artifact(source_dir: &Path, crate_name: &str) -> Option<PathBuf> {
- let artifact_name = crate_name.replace('-', "_");
-
- // Crate-local target dir (CI, default cargo)
- for target_triple in &["wasm32-wasip2", "wasm32-wasip1", "wasm32-wasi"] {
- let candidate = source_dir
- .join("target")
- .join(target_triple)
- .join("release")
- .join(format!("{artifact_name}.wasm"));
- if candidate.exists() {
- return Some(candidate);
- }
- }
-
- // Shared target dir (CARGO_TARGET_DIR env)
- if let Ok(shared) = std::env::var("CARGO_TARGET_DIR") {
- for target_triple in &["wasm32-wasip2", "wasm32-wasip1", "wasm32-wasi"] {
- let candidate = Path::new(&shared)
- .join(target_triple)
- .join("release")
- .join(format!("{artifact_name}.wasm"));
- if candidate.exists() {
- return Some(candidate);
- }
- }
- }
-
- // Common shared target location (~/.cargo/shared-target)
- if let Some(home) = dirs::home_dir() {
- let shared = home.join(".cargo/shared-target");
- if shared.exists() {
- for target_triple in &["wasm32-wasip2", "wasm32-wasip1", "wasm32-wasi"] {
- let candidate = shared
- .join(target_triple)
- .join("release")
- .join(format!("{artifact_name}.wasm"));
- if candidate.exists() {
- return Some(candidate);
- }
- }
- }
- }
-
- None
-}
-
/// Parse registry manifests to discover all WASM extensions.
for ext in &tool_extensions {
- let wasm_path = match find_wasm_artifact(&ext.source_dir, &ext.crate_name) {
+ let wasm_path = match ironclaw::registry::artifacts::find_wasm_artifact(
+ &ext.source_dir,
+ &ext.crate_name,
+ "release",
+ ) {
Some(p) => p,
for ext in &channel_extensions {
- let wasm_path = match find_wasm_artifact(&ext.source_dir, &ext.crate_name) {
+ let wasm_path = match ironclaw::registry::artifacts::find_wasm_artifact(
+ &ext.source_dir,
+ &ext.crate_name,
+ "release",
+ ) {
Some(p) => p,Excess Number of Function Argumentssrc/channels/wasm/wrapper/dispatch.rs: WasmChannel.dispatch_emitted_messages What lead to degradation?WasmChannel.dispatch_emitted_messages has 6 arguments, max arguments = 4 Why does this problem occur?Functions with many arguments indicate either a) low cohesion where the function has too many responsibilities, or b) a missing abstraction that encapsulates those arguments. How to fix it?Start by investigating the responsibilities of the function. Make sure it doesn't do too many things, in which case it should be split into smaller and more cohesive functions. Consider the refactoring INTRODUCE PARAMETER OBJECT to encapsulate arguments that refer to the same logical concept. |
|
Tip For best results, initiate chat on the files or code changes.
File: FixExtract the shared per-message dispatch pipeline and introduce a parameter object for polling dispatch state. Both methods currently perform the same responsibilities inline:
Move steps 2, 3, and 5 into helpers. Wrap the four state handles passed to AI coding-agent prompt |
Summary
This branch adds a Rust dependency-audit gate so CI can fail on cargo-audit
violations before vulnerable dependency paths are merged. It introduces a
Corbusier-style manifest walk in Makefile, installs
cargo-auditin test.yml, and upgrades the dependency graph in Cargo.toml and Cargo.lock to clear the failing audit paths.No roadmap task, issue, or execplan is associated with this branch.
Review walkthrough
auditandrust-audittargets, including the centralised advisory ignores that remain tied to libSQL's current Rustls/WebPKI dependency path.cargo-auditinstallation step, and the roll-up gate wiring.Validation
make audit: passed. The target still reports allowed warnings for upstream paths that cargo-audit classifies as warnings, while the Rustls/WebPKI advisory ignores are centralised in Makefile.cargo nextest run --workspace --features test-helpers --profile default tools::wasm::runtime::tests::test_enable_compilation_cache_with_explicit_dir tools::wasm::runtime::tests::test_enable_compilation_cache_label_isolation: passed.make all: passed, including format checks, all Clippy variants, 4,068 workspace tests, and the standalone GitHub tool tests.git diff --check: passed.Notes
hyper-rustls/ Rustls stack and are kept in one Makefile variable so they can be removed when libSQL updates that dependency path.cargo auditcan process the fuzz manifest during the repository-wide manifest walk.Summary by Sourcery
Introduce automated Rust dependency auditing in CI and update runtime dependencies to align with the new tooling requirements.
New Features:
Enhancements:
Build:
CI:
Tests: