Skip to content

ci: add clippy, fmt, and cargo-deny gates behind a CI Green aggregator - #158

Merged
getappz merged 3 commits into
masterfrom
ci/add-clippy-fmt-deny-gates
Jul 11, 2026
Merged

ci: add clippy, fmt, and cargo-deny gates behind a CI Green aggregator#158
getappz merged 3 commits into
masterfrom
ci/add-clippy-fmt-deny-gates

Conversation

@getappz

@getappz getappz commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds clippy, fmt, and cargo-deny jobs to CI, plus a CI Green aggregator job so branch protection can point at one stable required check (pattern adopted from lean-ctx's PR #721: feat: integrate lean-md as an external lean-ctx addon (+ LSP formatter routing) yvgude/lean-ctx#721)
  • clippy runs -D warnings but exempts unsafe_code and clippy::pedantic, preserving this repo's existing deliberate warn-only [lints] policy (root Cargo.toml + 3 sub-crates) instead of silently escalating it
  • deny.toml is adopted verbatim from lean-ctx (its license allow-list / bans / sources policy applies unchanged to agentflare's dependency tree — confirmed via a local cargo deny check run: advisories ok, bans ok, licenses ok, sources ok)
  • Runs cargo fmt across the whole workspace (no formatting enforcement existed before this) and fixes every clippy finding the new gate surfaces

Details

Clippy fixes were all either genuine bugs or pre-existing dead code:

  • crates/caveman/src/compress.rs: removed an unread placeholder initializer
  • crates/agentflare-artifacts/src/server.rs: redundant match guard
  • crates/agentflare-artifacts/src/store.rs: sort_bysort_by_key(Reverse(...))
  • crates/gateway-registry/src/error.rs: needless range loop in levenshtein
  • src/auth_runner.rs: reader.lines().flatten().map_while(Result::ok) (the old form loops forever if the stream errors without EOF)
  • src/auth_db.rs: collapsed two if/else if branches that returned the same value
  • src/cost.rs: nested format! in format! args; get().is_none()contains_key
  • src/shell.rs: suppressed enum_variant_names (renaming risks breaking match sites)
  • Targeted #[allow(dead_code)] / #[allow(clippy::too_many_arguments)] on pre-existing unused items and wide constructors across src/errors.rs, src/auth_db.rs, src/memory/{prompts,relations,sessions,observations}.rs, src/optimize.rs, src/mise_install.rs — none are behavior changes, all are out of scope to delete/refactor here

Test plan

  • cargo build --workspace
  • cargo test --workspace (323 passed, 0 failed)
  • cargo fmt --check clean
  • cargo clippy --workspace --all-targets --all-features -- -D warnings -A unsafe_code -A clippy::pedantic clean
  • cargo deny check clean (only warn-level duplicate-version notices, no errors)
  • CI green on this PR

Summary by CodeRabbit

  • Chores
    • Added CI quality gates for Rust linting (Clippy), formatting checks (rustfmt), and dependency policy enforcement (cargo-deny).
    • Introduced an aggregated “CI green” check that verifies all required jobs pass.
  • Tests
    • Continued and expanded automated coverage across agents, artifacts, gateway, memory, skills, and CLI flows.
  • Bug Fixes
    • Reduced the Claude HTTP request timeout used for LLM calls.
    • Improved stderr capture behavior during auth-related subprocess runs.
    • Normalized claim repository names using a more consistent split rule.

Adopts the CI check pattern from lean-ctx's PR #721: cargo clippy
(-D warnings, exempting the repo's existing warn-only unsafe_code and
clippy::pedantic policy), cargo fmt --check, and cargo-deny (license
and dependency policy, deny.toml adopted verbatim from lean-ctx since
its allow-list/bans/sources policy applies unchanged here). A CI Green
job aggregates build/clippy/fmt/deny so branch protection can point at
one stable check instead of every individual leg.

Also runs cargo fmt across the whole workspace (first pass, no prior
formatting enforcement existed) and fixes every clippy finding the new
gate surfaces: real bugs (redundant match guard, needless range loop,
unnecessary sort_by, lines().flatten() looping forever on stream
errors, duplicated if/else branches, nested format! args), plus
targeted #[allow] suppressions for pre-existing dead code and
too-many-arguments functions that are out of scope for this change.
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e325d1ce-0e02-47ea-a610-70cce810dc17

📥 Commits

Reviewing files that changed from the base of the PR and between a6f61f0 and 59ca9f8.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml
  • src/agent_launch.rs
✅ Files skipped from review due to trivial changes (1)
  • src/agent_launch.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/ci.yml

📝 Walkthrough

Walkthrough

The PR adds Clippy, formatting, cargo-deny, and aggregate CI checks. It introduces cargo-deny policy configuration and applies broad Rust formatting, lint annotations, idiomatic refactors, and unchanged-behavior test updates across workspace crates and application modules.

Changes

Repository-wide CI and Rust cleanup

Layer / File(s) Summary
Required CI checks and dependency policy
.github/workflows/ci.yml, deny.toml
Adds clippy, fmt, deny, and ci-green jobs, plus cargo-deny advisory, license, ban, and source policies.
Workspace Rust cleanup
crates/*, src/*, tests/*
Reformats Rust expressions and tests, adds selected #[must_use] and lint-suppression attributes, and applies small idiomatic rewrites while preserving described behavior.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Possibly related PRs

Suggested labels: enhancement, rust

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main CI gate additions and the CI Green aggregator.
Description check ✅ Passed The description covers summary and test plan well; the Notes for reviewers section is missing, but the rest is sufficiently complete.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/add-clippy-fmt-deny-gates

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

Comment thread .github/workflows/ci.yml Fixed
Comment thread .github/workflows/ci.yml Fixed
Comment thread .github/workflows/ci.yml Fixed
Comment thread .github/workflows/ci.yml Fixed
- The dtolnay/rust-toolchain and EmbarkStudios/cargo-deny-action SHAs
  copied from lean-ctx's workflow do not exist in those repos (zizmor's
  impostor-commit audit, confirmed independently via the GitHub API).
  Repinned both to their actual, verified commits.
- crates/agentflare-artifacts/src/store.rs: CI's clippy (newer toolchain
  than local) flagged a redundant `&` in format!("/{}", &id) —
  useless_borrows_in_formatting.

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)

93-94: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Run Clippy with the committed lockfile.

Add --locked; otherwise Cargo may update Cargo.lock during CI and lint a dependency graph different from the one reviewed. Apply the same reproducibility policy to the existing build/test commands.

[details]

-        run: cargo clippy --workspace --all-targets --all-features -- -D warnings -A unsafe_code -A clippy::pedantic
+        run: cargo clippy --locked --workspace --all-targets --all-features -- -D warnings -A unsafe_code -A clippy::pedantic

[/details]

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml around lines 93 - 94, Update the Clippy command in
the workflow to include Cargo’s --locked flag, then apply the same flag to the
existing Cargo build and test commands so CI always uses the committed
Cargo.lock without modifying or resolving dependencies.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 72-154: Add an explicit least-privilege permissions declaration
for the workflow, granting only contents: read to the checkout and CI jobs; if
permissions are scoped per job, set ci-green permissions to {} since it does not
access repository contents. Place the declaration at the workflow level or apply
equivalent job-level settings without changing the existing gate behavior.

In `@deny.toml`:
- Line 10: Update the cargo-deny policy settings for yanked crates, unknown
registries, and unknown Git sources to use deny-level enforcement instead of
warnings, while preserving any intentional explicit exceptions. Ensure the
dependency source policy, including allow-git, causes CI to fail for unapproved
sources.

In `@src/agent_launch.rs`:
- Around line 322-324: Update the test around run_launch to use an explicit
match that asserts the NotFound message contains “not found on PATH” and panics
for Launched, UnknownAgent, or Extension outcomes, ensuring unexpected launch
results fail the test.

---

Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 93-94: Update the Clippy command in the workflow to include
Cargo’s --locked flag, then apply the same flag to the existing Cargo build and
test commands so CI always uses the committed Cargo.lock without modifying or
resolving dependencies.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 72d51444-8acb-4492-99b9-12487de94ecc

📥 Commits

Reviewing files that changed from the base of the PR and between 1027124 and 34d7f6b.

📒 Files selected for processing (108)
  • .github/workflows/ci.yml
  • crates/agent-registry/src/detect.rs
  • crates/agent-registry/src/lib.rs
  • crates/agent-registry/src/registry.rs
  • crates/agentflare-artifacts/src/lib.rs
  • crates/agentflare-artifacts/src/server.rs
  • crates/agentflare-artifacts/src/store.rs
  • crates/caveman/src/compress.rs
  • crates/caveman/src/lib.rs
  • crates/caveman/src/llm.rs
  • crates/caveman/src/prompt.rs
  • crates/caveman/src/sensitive.rs
  • crates/caveman/src/validate.rs
  • crates/gateway-registry/src/audit.rs
  • crates/gateway-registry/src/circuit.rs
  • crates/gateway-registry/src/config.rs
  • crates/gateway-registry/src/db.rs
  • crates/gateway-registry/src/error.rs
  • crates/gateway-registry/src/lib.rs
  • crates/gateway-registry/src/mcp_http.rs
  • crates/gateway-registry/src/mcp_stdio.rs
  • crates/gateway-registry/src/redact.rs
  • crates/gateway-registry/src/registry.rs
  • crates/gateway-registry/src/sanitize.rs
  • crates/gateway-registry/src/search.rs
  • crates/gateway-registry/src/truncate.rs
  • crates/gateway-registry/tests/fixtures/fixture_server.rs
  • crates/gateway-registry/tests/gateway_audit_log.rs
  • crates/gateway-registry/tests/mcp_http_call.rs
  • crates/gateway-registry/tests/mcp_http_circuit_breaker.rs
  • crates/gateway-registry/tests/mcp_http_discover.rs
  • crates/gateway-registry/tests/mcp_stdio_call.rs
  • crates/gateway-registry/tests/mcp_stdio_circuit_breaker.rs
  • crates/gateway-registry/tests/mcp_stdio_discover.rs
  • crates/gateway-registry/tests/mcp_stdio_reconnect.rs
  • crates/gateway-registry/tests/mcp_stdio_timeout.rs
  • crates/gateway-registry/tests/registry.rs
  • crates/gateway-registry/tests/support/mod.rs
  • crates/ponytail/src/config.rs
  • crates/ponytail/src/detect.rs
  • crates/ponytail/src/instructions.rs
  • crates/ponytail/src/lib.rs
  • crates/ponytail/src/platform.rs
  • crates/ponytail/src/state.rs
  • crates/ponytail/src/sub_skills.rs
  • crates/ponytail/src/switcher.rs
  • crates/skill-registry/src/db.rs
  • crates/skill-registry/src/frontmatter.rs
  • crates/skill-registry/src/lib.rs
  • crates/skill-registry/src/load.rs
  • crates/skill-registry/src/search.rs
  • crates/skill-registry/src/sources.rs
  • crates/skill-registry/tests/golden_queries.rs
  • deny.toml
  • src/agent_install.rs
  • src/agent_launch.rs
  • src/agents.rs
  • src/alias.rs
  • src/auth.rs
  • src/auth_crypt.rs
  • src/auth_db.rs
  • src/auth_runner.rs
  • src/build_time.rs
  • src/channels.rs
  • src/claims.rs
  • src/cli/agents.rs
  • src/cli/auth.rs
  • src/cli/caveman.rs
  • src/cli/channel.rs
  • src/cli/claim.rs
  • src/cli/coaching.rs
  • src/cli/gateway.rs
  • src/cli/handoff.rs
  • src/cli/memory.rs
  • src/cli/ponytail.rs
  • src/cli/review.rs
  • src/coaching.rs
  • src/components.rs
  • src/cost.rs
  • src/db.rs
  • src/dev_vars.rs
  • src/errors.rs
  • src/gateway_integrations.rs
  • src/gateway_secrets.rs
  • src/hook.rs
  • src/init.rs
  • src/main.rs
  • src/mcp_prompts.rs
  • src/mcp_server.rs
  • src/memory/mcp.rs
  • src/memory/observations.rs
  • src/memory/prompts.rs
  • src/memory/relations.rs
  • src/memory/search.rs
  • src/memory/sessions.rs
  • src/memory/store.rs
  • src/memory/summaries.rs
  • src/mise_install.rs
  • src/optimize.rs
  • src/pricing.rs
  • src/review.rs
  • src/rollup.rs
  • src/shell.rs
  • src/state.rs
  • src/tool_install.rs
  • src/uninstall.rs
  • src/update.rs
  • tests/caveman_cli.rs

Comment thread .github/workflows/ci.yml
Comment thread deny.toml
# all vulnerability/notice advisories now emit errors unless explicitly ignored.
# `unmaintained`/`unsound` now control which dependencies can fail the check.
unmaintained = "workspace"
yanked = "warn"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the policy file and any cargo-deny references
git ls-files | rg '(^|/)deny\.toml$|cargo-deny|deny\.(toml|ya?ml)$|\.cargo-deny'

# Show the relevant section with line numbers
if [ -f deny.toml ]; then
  cat -n deny.toml | sed -n '1,140p'
fi

# Search for any documented intent around yanked / git / registry policy
rg -n --hidden --no-ignore-vcs 'yanked|unknown-registry|unknown-git|allow-git|cargo-deny' .

Repository: getappz/agentflare

Length of output: 2453


🌐 Web query:

cargo-deny configuration warn deny yanked unknown-registry unknown-git allow-git warnings fail the check semantics

💡 Result:

In cargo-deny, configuration fields such as yanked, unknown-registry, and unknown-git control how the tool evaluates dependency sources and advisories [1][2][3]. These fields accept a lint level, which determines the outcome of the check [2][4][5]. The standard lint levels are: - deny: The tool will emit an error and the check will fail (returning a non-zero exit code) [2][5][6]. - warn: The tool will emit a warning diagnostic, but the check will not fail [2][5][6]. - allow: No warning or error is produced [2][5][6]. Specific behaviors for your listed fields include: - yanked: Found under the [advisories] section, this controls the response when a crate version has been yanked from its registry [3]. Setting this to deny will fail the check if any dependency is yanked [3]. - unknown-registry and unknown-git: Found under the [sources] section, these define how to handle crates sourced from registries or git repositories not explicitly listed in allow-registry or allow-git [2][7][4]. Setting these to deny will fail the check if a dependency is found from an unapproved source [2][4]. - allow-git: This is a configuration list rather than a lint level; it specifies the allowed git repository URLs [2][7]. If a crate's source is not in this list, the behavior is determined by the unknown-git lint level [7]. By default, many of these fields are set to warn [2][3][5]. To enforce strict policies, you must explicitly set these values to deny in your deny.toml file [2][8].

Citations:


🌐 Web query:

cargo-deny config severity warn deny yanked unknown-registry unknown-git action behavior

💡 Result:

In cargo-deny, several configuration options control the severity of checks, which determines the action taken when a violation occurs [1]. These severity levels are defined as lint levels [1]: - deny: Produces an error and causes the check to fail [1]. - warn: Produces a warning, but the check will not fail [1]. - allow: Produces no warning or error [1]. Specific configuration behaviors for the fields mentioned are as follows: yanked The [advisories] section includes a setting for yanked crates [2]. It determines the action taken when a crate version that has been yanked from its registry is encountered [2]. You can set this to deny to emit an error, or configure other levels depending on your project needs [2]. Additionally, specific yanked versions can be ignored by adding them to the ignore list in the [advisories] section [1]. unknown-registry This setting, found in the [sources] section, controls what happens when a crate is sourced from a registry not included in the allow-registry list [1][3]. The default behavior is typically set to warn, but it can be changed to deny to enforce stricter registry compliance [1][3]. unknown-git Similar to unknown-registry, this setting in the [sources] section controls the behavior when a crate is sourced from a Git repository not listed in the allow-git configuration [1][4]. It also supports the standard lint levels, with the default often set to warn [1][5]. In summary, for these settings, you define the desired severity (allow, warn, or deny) to dictate whether cargo-deny should permit the dependency, warn the developer, or fail the build [1].

Citations:


Enforce the dependency source and yanked-crate policy.
yanked, unknown-registry, and unknown-git are set to warn, so cargo-deny will only emit warnings and CI can still pass. allow-git = [] is not enforced unless unknown-git is deny; switch these to deny or add explicit exceptions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@deny.toml` at line 10, Update the cargo-deny policy settings for yanked
crates, unknown registries, and unknown Git sources to use deny-level
enforcement instead of warnings, while preserving any intentional explicit
exceptions. Ensure the dependency source policy, including allow-git, causes CI
to fail for unapproved sources.

Comment thread src/agent_launch.rs Outdated
…ed, stricter test

- Add explicit `permissions: contents: read` to the build/clippy/fmt/deny
  jobs (only `changes` had it) and `permissions: {}` to ci-green, which
  never checks out the repo.
- Run the new clippy job with --locked so CI lints the committed
  Cargo.lock instead of silently letting cargo re-resolve it.
- src/agent_launch.rs: launch_not_on_path_errors used `if let` so it
  silently passed on any outcome other than NotFound; switched to an
  exhaustive match that panics on Launched/UnknownAgent/Extension.
  Needed LaunchOutcome to derive Debug for the panic message.

Skipped CodeRabbit's deny.toml suggestion (escalate yanked/unknown-registry/
unknown-git from warn to deny) — deny.toml was deliberately adopted verbatim
from lean-ctx's already-tuned policy per an explicit ask; changing its
semantics needs a separate decision, not folding into this CI-gates PR.
@getappz

getappz commented Jul 11, 2026

Copy link
Copy Markdown
Owner Author

Addressed in 59ca9f8:

  • Added permissions: contents: read to the build/clippy/fmt/deny jobs and permissions: {} to ci-green.
  • Added --locked to the new clippy job.
  • Fixed launch_not_on_path_errors to use an exhaustive match instead of if let, so it actually fails on unexpected LaunchOutcome variants.

Intentionally not applying the deny.toml suggestion (escalating yanked/unknown-registry/unknown-git from warn to deny): deny.toml was adopted verbatim from lean-ctx's own tuned cargo-deny policy at the repo owner's explicit request. Changing its enforcement semantics is a separate policy decision, not something to fold silently into a CI-gates PR.

@getappz
getappz merged commit efb90b6 into master Jul 11, 2026
15 checks passed
@getappz
getappz deleted the ci/add-clippy-fmt-deny-gates branch July 11, 2026 22:39
@github-actions github-actions Bot mentioned this pull request Jul 12, 2026
getappz added a commit that referenced this pull request Aug 21, 2026
#573)

Same architectural gap as skill-registry (#519/PR #572), which
gateway-registry's own doc comments say it mirrors: hand-rolled
apply_schema() with no user_version tracking. Audited the git history
(#104 -> #158 -> #347) -- the tools table's columns have never changed
since creation, so there's no live "no such column" bug today, but the
next column addition would hit the identical class of bug.

Migrates to agentflare-db-kit's open_file/open_memory with a real
migration list: 0001_initial replays the original (#104) narrow schema,
0002_fts_triggers unconditionally drops and recreates tools_fts as the
external-content shape with sync triggers plus a backfill. No ALTER
TABLE/migration hook needed here (unlike #519) since tools's columns
are stable -- DROP ... IF EXISTS before a fresh CREATE is correct
regardless of which pre-migration shape existed.

Added GatewayError::DbInit for db_kit::open::Error and its error_kind
match arm. All 60 gateway-registry unit tests pass, including the
existing legacy-standalone-FTS conversion test; clippy (with the CI
gate flags) and fmt are clean; the full agentflare binary compiles.

Agentflare-Agent: claude-code_2-1-237_agent
Agentflare-Branch: task/520-fix-gateway-registry-adopt-agentflare-db
Agentflare-Item: 520
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.

2 participants