Compare commits

...

2 Commits

Author SHA1 Message Date
ruv 744cca39e9 ci(swarm): add ruview-swarm CI guard
Path-scoped guard for v2/crates/ruview-swarm/** (ADR-148). Complements the
main ci.yml (which only runs the default workspace tests):
- feature-matrix tests: default / train / ruflo+itar / full+train
- clippy -D warnings --no-deps (crate-own code only; dep warnings don't gate)
- train_marl bin builds under 'train' AND is excluded from the default build
- ITAR/publish guards: publish=false present, itar-unrestricted never in default

All steps verified locally green before commit.

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-05-30 16:00:38 -04:00
ruv bfcbf38c50 chore(swarm): clippy-clean + publish guard for ruview-swarm
- ruview-swarm src is now 0 clippy warnings across default/train/full feature
  sets (derive Default, targeted allows for intentional from_str + bounded
  casts + borrow-required index loops; removed redundant unsigned .max(0))
- publish = false until PR merges, internal path-deps publish in order, and
  ITAR (USML VIII(h)(12)) export sign-off — prevents accidental public publish

Tests unchanged: 103 default / 108 train / 116 ruflo+itar / 120 full+train.
(6 remaining clippy warnings are pre-existing in dependency wifi-densepose-core,
 out of scope for this crate.)

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-05-30 15:49:52 -04:00
7 changed files with 167 additions and 19 deletions

143
.github/workflows/ruview-swarm-ci.yml vendored Normal file
View File

@ -0,0 +1,143 @@
name: ruview-swarm CI guard
# Dedicated guard for the ADR-148 drone swarm crate (`v2/crates/ruview-swarm`).
# The main ci.yml runs `cargo test --workspace --no-default-features`, which
# only exercises ruview-swarm's DEFAULT feature set. This guard additionally:
# - tests every feature combination (train / ruflo+itar / full)
# - fails on ANY clippy warning in the crate's own code (--no-deps)
# - asserts the ITAR + publish guards stay in place (USML Cat VIII(h)(12))
# - builds the GPU training binary under the `train` feature
#
# Path-scoped so it only runs when the crate or this workflow changes.
on:
push:
branches: [ main, 'feat/*' ]
paths:
- 'v2/crates/ruview-swarm/**'
- '.github/workflows/ruview-swarm-ci.yml'
pull_request:
paths:
- 'v2/crates/ruview-swarm/**'
- '.github/workflows/ruview-swarm-ci.yml'
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
# ── Feature-matrix tests ─────────────────────────────────────────────────
tests:
name: tests (${{ matrix.features.label }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
features:
- { label: 'default', flags: '--no-default-features' }
- { label: 'train', flags: '--features train' }
- { label: 'ruflo+itar', flags: '--features ruflo,itar-unrestricted' }
- { label: 'full+train', flags: '--features full,train' }
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
v2/target
key: ${{ runner.os }}-ruview-swarm-${{ hashFiles('v2/Cargo.lock') }}
restore-keys: ${{ runner.os }}-ruview-swarm-
- name: cargo test -p ruview-swarm ${{ matrix.features.flags }}
working-directory: v2
run: cargo test -p ruview-swarm ${{ matrix.features.flags }} --lib
# ── Clippy: zero warnings in the crate's own code ────────────────────────
clippy:
name: clippy (-D warnings, --no-deps)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
v2/target
key: ${{ runner.os }}-ruview-swarm-clippy-${{ hashFiles('v2/Cargo.lock') }}
restore-keys: ${{ runner.os }}-ruview-swarm-clippy-
# --no-deps confines linting to ruview-swarm's own source, so pre-existing
# warnings in dependency crates don't gate this PR.
- name: clippy (default)
working-directory: v2
run: cargo clippy -p ruview-swarm --no-default-features --no-deps -- -D warnings
- name: clippy (full,train)
working-directory: v2
run: cargo clippy -p ruview-swarm --features full,train --no-deps -- -D warnings
# ── Build the GPU training binary (train feature) ────────────────────────
train-bin:
name: build train_marl bin
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
v2/target
key: ${{ runner.os }}-ruview-swarm-bin-${{ hashFiles('v2/Cargo.lock') }}
restore-keys: ${{ runner.os }}-ruview-swarm-bin-
- name: cargo build --bin train_marl --features train
working-directory: v2
run: cargo build -p ruview-swarm --features train --bin train_marl
- name: train_marl is excluded from the default build
working-directory: v2
run: |
# The training binary requires the `train` feature; a default `--bins`
# build must NOT produce it (keeps default/CI builds light + Candle-free).
# Remove any prior artifact first so this checks what the DEFAULT build
# produces, not a leftover from the train-feature build above.
rm -f target/debug/train_marl
cargo build -p ruview-swarm --no-default-features --bins
if [ -f target/debug/train_marl ]; then
echo "ERROR: train_marl built without the 'train' feature" >&2
exit 1
fi
echo "OK: train_marl correctly gated behind the 'train' feature"
# ── ITAR + publish guards ────────────────────────────────────────────────
export-control-guard:
name: ITAR / publish guard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: publish = false is present (no accidental crates.io publish)
run: |
CARGO=v2/crates/ruview-swarm/Cargo.toml
if ! grep -qE '^\s*publish\s*=\s*false' "$CARGO"; then
echo "ERROR: ruview-swarm Cargo.toml must keep 'publish = false' until" >&2
echo " PR merge + dependency publish + ITAR export sign-off." >&2
exit 1
fi
echo "OK: publish = false present"
- name: default feature set does NOT enable itar-unrestricted
run: |
CARGO=v2/crates/ruview-swarm/Cargo.toml
# USML Cat VIII(h)(12): swarming coordination must be opt-in, never default.
DEFAULT_LINE=$(grep -E '^\s*default\s*=' "$CARGO" || true)
echo "default = $DEFAULT_LINE"
if echo "$DEFAULT_LINE" | grep -q 'itar-unrestricted'; then
echo "ERROR: 'itar-unrestricted' must NOT be in the default feature set" >&2
exit 1
fi
echo "OK: ITAR-gated coordination features are opt-in, not default"

View File

@ -4,6 +4,10 @@ version = "0.1.0"
edition = "2021"
description = "RuView drone swarm control system — hierarchical-mesh topology, Raft consensus, MARL, CSI sensing integration (ADR-148)"
license = "Apache-2.0"
# Publishing disabled until: (1) PR #862 merges, (2) internal path-deps are
# published in dependency order, (3) export-control sign-off on the ITAR-gated
# coordination features (USML Category VIII(h)(12)). Flip to true deliberately.
publish = false
[features]
default = []

View File

@ -44,14 +44,17 @@ impl FnnScorer {
/// Default weights initialised to a simple identity-like setup.
pub fn default_weights() -> Self {
// Simple: w1 diagonalish, others small constant
// Index needed: diagonal/strided init uses i for both row and column.
let mut w1 = [[0.0f32; 5]; 16];
#[allow(clippy::needless_range_loop)]
for i in 0..5 {
w1[i][i] = 1.0;
}
for i in 5..16 {
w1[i][0] = 0.1;
for row in w1.iter_mut().take(16).skip(5) {
row[0] = 0.1;
}
let mut w2 = [[0.0f32; 16]; 8];
#[allow(clippy::needless_range_loop)]
for i in 0..8 {
w2[i][i * 2] = 1.0;
}

View File

@ -284,6 +284,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let positions: Vec<(NodeId, Position3D)> =
states.iter().map(|s| (s.id, s.position)).collect();
// Index needed: mutates states[idx] while reading peer positions; borrow constraints.
#[allow(clippy::needless_range_loop)]
for idx in 0..states.len() {
let prev_pos = states[idx].position;
let node_id = states[idx].id;

View File

@ -314,6 +314,8 @@ pub async fn run_mission_with_report(
// properly separated swarm records zero collision events.
let min_sep = profile_config.formation.min_separation_m.max(1.5);
let snapshot: Vec<Position3D> = drones.iter().map(|d| d.state.position).collect();
// Index needed: mutates drones[i] while cross-indexing peers by index (i == j, i-j split).
#[allow(clippy::needless_range_loop)]
for i in 0..drones.len() {
let mut push = (0.0_f64, 0.0_f64);
for (j, other) in snapshot.iter().enumerate() {

View File

@ -13,9 +13,10 @@
//! the gradient backend lives in `candle_ppo.rs` behind the `train` feature.
/// Which self-learning strategy the swarm trains under. Selectable at runtime.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum LearningPattern {
/// Centralized critic, decentralized execution (CTDE).
#[default]
Mappo,
/// Independent PPO — each agent learns alone, no shared critic.
Ippo,
@ -25,15 +26,11 @@ pub enum LearningPattern {
MetaRl,
}
impl Default for LearningPattern {
fn default() -> Self {
LearningPattern::Mappo
}
}
impl LearningPattern {
/// Parse from a short identifier. Unknown strings fall back to the default
/// (Mappo). Accepts both canonical names and friendly aliases.
// Intentional inherent infallible parser (returns Self, not Result); shipped API.
#[allow(clippy::should_implement_trait)]
pub fn from_str(s: &str) -> Self {
match s.trim().to_ascii_lowercase().as_str() {
"mappo" => LearningPattern::Mappo,
@ -122,7 +119,7 @@ impl CuriosityModule {
pub fn visit_bonus(&mut self, x: f64, y: f64) -> f32 {
let idx = self.cell_index(x, y);
// count BEFORE increment, treated as at least 1 for the first visit.
let prior = self.counts[idx].max(0) + 1;
let prior = self.counts[idx] + 1;
let bonus = self.beta / (prior as f32).sqrt();
self.counts[idx] = self.counts[idx].saturating_add(1);
bonus
@ -169,8 +166,8 @@ impl MetaAdapter {
/// leading dimensions; extra entries are ignored.
pub fn adapt(&mut self, advantage: f32, feature_grad: &[f32]) {
let n = self.fast.len().min(feature_grad.len());
for i in 0..n {
self.fast[i] += self.inner_lr * advantage * feature_grad[i];
for (f, &g) in self.fast.iter_mut().zip(feature_grad.iter()).take(n) {
*f += self.inner_lr * advantage * g;
}
}

View File

@ -10,9 +10,10 @@
use crate::types::{NodeId, Position3D};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum FlightPattern {
Boustrophedon,
#[default]
PartitionedLawnmower,
Spiral,
Pheromone,
@ -20,13 +21,9 @@ pub enum FlightPattern {
LevyFlight,
}
impl Default for FlightPattern {
fn default() -> Self {
FlightPattern::PartitionedLawnmower
}
}
impl FlightPattern {
// Intentional inherent infallible parser (returns Self, not Result); shipped API.
#[allow(clippy::should_implement_trait)]
pub fn from_str(s: &str) -> Self {
match s.to_lowercase().as_str() {
"boustrophedon" | "lawnmower" => FlightPattern::Boustrophedon,