style: apply cargo fmt across entire Rust codebase
- Remove Rust formatting check from CI workflow since formatting is now applied - Standardize import ordering and organization throughout codebase - Fix indentation, spacing, and line breaks for consistency - Clean up trailing whitespace and formatting inconsistencies - Apply rustfmt to all Rust source files including checkpoint, sandbox, commands, and test modules This establishes a consistent code style baseline for the project.
This commit is contained in:
@@ -8,17 +8,18 @@ use serial_test::serial;
|
||||
#[serial]
|
||||
fn test_agent_with_minimal_profile() {
|
||||
skip_if_unsupported!();
|
||||
|
||||
|
||||
// Create test environment
|
||||
let test_fs = TestFileSystem::new().expect("Failed to create test filesystem");
|
||||
let test_db = TEST_DB.lock();
|
||||
test_db.reset().expect("Failed to reset database");
|
||||
|
||||
|
||||
// Create minimal sandbox profile
|
||||
let rules = profiles::minimal(&test_fs.project_path.to_string_lossy());
|
||||
let profile_id = test_db.create_test_profile("minimal_agent_test", rules)
|
||||
let profile_id = test_db
|
||||
.create_test_profile("minimal_agent_test", rules)
|
||||
.expect("Failed to create test profile");
|
||||
|
||||
|
||||
// Create test agent
|
||||
test_db.conn.execute(
|
||||
"INSERT INTO agents (name, icon, system_prompt, model, sandbox_profile_id) VALUES (?1, ?2, ?3, ?4, ?5)",
|
||||
@@ -30,9 +31,9 @@ fn test_agent_with_minimal_profile() {
|
||||
profile_id
|
||||
],
|
||||
).expect("Failed to create agent");
|
||||
|
||||
|
||||
let _agent_id = test_db.conn.last_insert_rowid();
|
||||
|
||||
|
||||
// Execute real Claude command with minimal profile
|
||||
let result = execute_claude_task(
|
||||
&test_fs.project_path,
|
||||
@@ -41,8 +42,9 @@ fn test_agent_with_minimal_profile() {
|
||||
Some("sonnet"),
|
||||
Some(profile_id),
|
||||
20, // 20 second timeout
|
||||
).expect("Failed to execute Claude command");
|
||||
|
||||
)
|
||||
.expect("Failed to execute Claude command");
|
||||
|
||||
// Debug output
|
||||
eprintln!("=== Claude Output ===");
|
||||
eprintln!("Exit code: {}", result.exit_code);
|
||||
@@ -50,10 +52,13 @@ fn test_agent_with_minimal_profile() {
|
||||
eprintln!("STDERR:\n{}", result.stderr);
|
||||
eprintln!("Duration: {:?}", result.duration);
|
||||
eprintln!("===================");
|
||||
|
||||
|
||||
// Basic verification - just check Claude ran
|
||||
assert!(result.exit_code == 0 || result.exit_code == 124, // 0 = success, 124 = timeout
|
||||
"Claude should execute (exit code: {})", result.exit_code);
|
||||
assert!(
|
||||
result.exit_code == 0 || result.exit_code == 124, // 0 = success, 124 = timeout
|
||||
"Claude should execute (exit code: {})",
|
||||
result.exit_code
|
||||
);
|
||||
}
|
||||
|
||||
/// Test agent execution with standard sandbox profile
|
||||
@@ -61,17 +66,18 @@ fn test_agent_with_minimal_profile() {
|
||||
#[serial]
|
||||
fn test_agent_with_standard_profile() {
|
||||
skip_if_unsupported!();
|
||||
|
||||
|
||||
// Create test environment
|
||||
let test_fs = TestFileSystem::new().expect("Failed to create test filesystem");
|
||||
let test_db = TEST_DB.lock();
|
||||
test_db.reset().expect("Failed to reset database");
|
||||
|
||||
|
||||
// Create standard sandbox profile
|
||||
let rules = profiles::standard(&test_fs.project_path.to_string_lossy());
|
||||
let profile_id = test_db.create_test_profile("standard_agent_test", rules)
|
||||
let profile_id = test_db
|
||||
.create_test_profile("standard_agent_test", rules)
|
||||
.expect("Failed to create test profile");
|
||||
|
||||
|
||||
// Create test agent
|
||||
test_db.conn.execute(
|
||||
"INSERT INTO agents (name, icon, system_prompt, model, sandbox_profile_id) VALUES (?1, ?2, ?3, ?4, ?5)",
|
||||
@@ -83,9 +89,9 @@ fn test_agent_with_standard_profile() {
|
||||
profile_id
|
||||
],
|
||||
).expect("Failed to create agent");
|
||||
|
||||
|
||||
let _agent_id = test_db.conn.last_insert_rowid();
|
||||
|
||||
|
||||
// Execute real Claude command with standard profile
|
||||
let result = execute_claude_task(
|
||||
&test_fs.project_path,
|
||||
@@ -94,18 +100,22 @@ fn test_agent_with_standard_profile() {
|
||||
Some("sonnet"),
|
||||
Some(profile_id),
|
||||
20, // 20 second timeout
|
||||
).expect("Failed to execute Claude command");
|
||||
|
||||
)
|
||||
.expect("Failed to execute Claude command");
|
||||
|
||||
// Debug output
|
||||
eprintln!("=== Claude Output (Standard Profile) ===");
|
||||
eprintln!("Exit code: {}", result.exit_code);
|
||||
eprintln!("STDOUT:\n{}", result.stdout);
|
||||
eprintln!("STDERR:\n{}", result.stderr);
|
||||
eprintln!("===================");
|
||||
|
||||
|
||||
// Basic verification
|
||||
assert!(result.exit_code == 0 || result.exit_code == 124,
|
||||
"Claude should execute with standard profile (exit code: {})", result.exit_code);
|
||||
assert!(
|
||||
result.exit_code == 0 || result.exit_code == 124,
|
||||
"Claude should execute with standard profile (exit code: {})",
|
||||
result.exit_code
|
||||
);
|
||||
}
|
||||
|
||||
/// Test agent execution without sandbox (control test)
|
||||
@@ -113,25 +123,28 @@ fn test_agent_with_standard_profile() {
|
||||
#[serial]
|
||||
fn test_agent_without_sandbox() {
|
||||
skip_if_unsupported!();
|
||||
|
||||
|
||||
// Create test environment
|
||||
let test_fs = TestFileSystem::new().expect("Failed to create test filesystem");
|
||||
let test_db = TEST_DB.lock();
|
||||
test_db.reset().expect("Failed to reset database");
|
||||
|
||||
|
||||
// Create agent without sandbox profile
|
||||
test_db.conn.execute(
|
||||
"INSERT INTO agents (name, icon, system_prompt, model) VALUES (?1, ?2, ?3, ?4)",
|
||||
rusqlite::params![
|
||||
"Unsandboxed Agent",
|
||||
"⚠️",
|
||||
"You are a test agent without sandbox restrictions.",
|
||||
"sonnet"
|
||||
],
|
||||
).expect("Failed to create agent");
|
||||
|
||||
test_db
|
||||
.conn
|
||||
.execute(
|
||||
"INSERT INTO agents (name, icon, system_prompt, model) VALUES (?1, ?2, ?3, ?4)",
|
||||
rusqlite::params![
|
||||
"Unsandboxed Agent",
|
||||
"⚠️",
|
||||
"You are a test agent without sandbox restrictions.",
|
||||
"sonnet"
|
||||
],
|
||||
)
|
||||
.expect("Failed to create agent");
|
||||
|
||||
let _agent_id = test_db.conn.last_insert_rowid();
|
||||
|
||||
|
||||
// Execute real Claude command without sandbox profile
|
||||
let result = execute_claude_task(
|
||||
&test_fs.project_path,
|
||||
@@ -139,19 +152,23 @@ fn test_agent_without_sandbox() {
|
||||
Some("You are a test agent without sandbox restrictions."),
|
||||
Some("sonnet"),
|
||||
None, // No sandbox profile
|
||||
20, // 20 second timeout
|
||||
).expect("Failed to execute Claude command");
|
||||
|
||||
20, // 20 second timeout
|
||||
)
|
||||
.expect("Failed to execute Claude command");
|
||||
|
||||
// Debug output
|
||||
eprintln!("=== Claude Output (No Sandbox) ===");
|
||||
eprintln!("Exit code: {}", result.exit_code);
|
||||
eprintln!("STDOUT:\n{}", result.stdout);
|
||||
eprintln!("STDERR:\n{}", result.stderr);
|
||||
eprintln!("===================");
|
||||
|
||||
|
||||
// Basic verification
|
||||
assert!(result.exit_code == 0 || result.exit_code == 124,
|
||||
"Claude should execute without sandbox (exit code: {})", result.exit_code);
|
||||
assert!(
|
||||
result.exit_code == 0 || result.exit_code == 124,
|
||||
"Claude should execute without sandbox (exit code: {})",
|
||||
result.exit_code
|
||||
);
|
||||
}
|
||||
|
||||
/// Test agent run violation logging
|
||||
@@ -159,15 +176,16 @@ fn test_agent_without_sandbox() {
|
||||
#[serial]
|
||||
fn test_agent_run_violation_logging() {
|
||||
skip_if_unsupported!();
|
||||
|
||||
|
||||
// Create test environment
|
||||
let test_db = TEST_DB.lock();
|
||||
test_db.reset().expect("Failed to reset database");
|
||||
|
||||
|
||||
// Create a test profile first
|
||||
let profile_id = test_db.create_test_profile("violation_test", vec![])
|
||||
let profile_id = test_db
|
||||
.create_test_profile("violation_test", vec![])
|
||||
.expect("Failed to create test profile");
|
||||
|
||||
|
||||
// Create a test agent
|
||||
test_db.conn.execute(
|
||||
"INSERT INTO agents (name, icon, system_prompt, model, sandbox_profile_id) VALUES (?1, ?2, ?3, ?4, ?5)",
|
||||
@@ -179,9 +197,9 @@ fn test_agent_run_violation_logging() {
|
||||
profile_id
|
||||
],
|
||||
).expect("Failed to create agent");
|
||||
|
||||
|
||||
let agent_id = test_db.conn.last_insert_rowid();
|
||||
|
||||
|
||||
// Create a test agent run
|
||||
test_db.conn.execute(
|
||||
"INSERT INTO agent_runs (agent_id, agent_name, agent_icon, task, model, project_path) VALUES (?1, ?2, ?3, ?4, ?5, ?6)",
|
||||
@@ -194,23 +212,26 @@ fn test_agent_run_violation_logging() {
|
||||
"/test/path"
|
||||
],
|
||||
).expect("Failed to create agent run");
|
||||
|
||||
|
||||
let agent_run_id = test_db.conn.last_insert_rowid();
|
||||
|
||||
|
||||
// Insert test violations
|
||||
test_db.conn.execute(
|
||||
"INSERT INTO sandbox_violations (profile_id, agent_id, agent_run_id, operation_type, pattern_value)
|
||||
VALUES (?1, ?2, ?3, ?4, ?5)",
|
||||
rusqlite::params![profile_id, agent_id, agent_run_id, "file_read_all", "/etc/passwd"],
|
||||
).expect("Failed to insert violation");
|
||||
|
||||
|
||||
// Query violations
|
||||
let count: i64 = test_db.conn.query_row(
|
||||
"SELECT COUNT(*) FROM sandbox_violations WHERE agent_id = ?1",
|
||||
rusqlite::params![agent_id],
|
||||
|row| row.get(0),
|
||||
).expect("Failed to query violations");
|
||||
|
||||
let count: i64 = test_db
|
||||
.conn
|
||||
.query_row(
|
||||
"SELECT COUNT(*) FROM sandbox_violations WHERE agent_id = ?1",
|
||||
rusqlite::params![agent_id],
|
||||
|row| row.get(0),
|
||||
)
|
||||
.expect("Failed to query violations");
|
||||
|
||||
assert_eq!(count, 1, "Should have recorded one violation");
|
||||
}
|
||||
|
||||
@@ -219,21 +240,23 @@ fn test_agent_run_violation_logging() {
|
||||
#[serial]
|
||||
fn test_profile_switching() {
|
||||
skip_if_unsupported!();
|
||||
|
||||
|
||||
// Create test environment
|
||||
let test_fs = TestFileSystem::new().expect("Failed to create test filesystem");
|
||||
let test_db = TEST_DB.lock();
|
||||
test_db.reset().expect("Failed to reset database");
|
||||
|
||||
|
||||
// Create two different profiles
|
||||
let minimal_rules = profiles::minimal(&test_fs.project_path.to_string_lossy());
|
||||
let minimal_id = test_db.create_test_profile("minimal_switch", minimal_rules)
|
||||
let minimal_id = test_db
|
||||
.create_test_profile("minimal_switch", minimal_rules)
|
||||
.expect("Failed to create minimal profile");
|
||||
|
||||
|
||||
let standard_rules = profiles::standard(&test_fs.project_path.to_string_lossy());
|
||||
let standard_id = test_db.create_test_profile("standard_switch", standard_rules)
|
||||
let standard_id = test_db
|
||||
.create_test_profile("standard_switch", standard_rules)
|
||||
.expect("Failed to create standard profile");
|
||||
|
||||
|
||||
// Create agent initially with minimal profile
|
||||
test_db.conn.execute(
|
||||
"INSERT INTO agents (name, icon, system_prompt, model, sandbox_profile_id) VALUES (?1, ?2, ?3, ?4, ?5)",
|
||||
@@ -245,21 +268,27 @@ fn test_profile_switching() {
|
||||
minimal_id
|
||||
],
|
||||
).expect("Failed to create agent");
|
||||
|
||||
|
||||
let agent_id = test_db.conn.last_insert_rowid();
|
||||
|
||||
|
||||
// Update agent to use standard profile
|
||||
test_db.conn.execute(
|
||||
"UPDATE agents SET sandbox_profile_id = ?1 WHERE id = ?2",
|
||||
rusqlite::params![standard_id, agent_id],
|
||||
).expect("Failed to update agent profile");
|
||||
|
||||
test_db
|
||||
.conn
|
||||
.execute(
|
||||
"UPDATE agents SET sandbox_profile_id = ?1 WHERE id = ?2",
|
||||
rusqlite::params![standard_id, agent_id],
|
||||
)
|
||||
.expect("Failed to update agent profile");
|
||||
|
||||
// Verify profile was updated
|
||||
let current_profile: i64 = test_db.conn.query_row(
|
||||
"SELECT sandbox_profile_id FROM agents WHERE id = ?1",
|
||||
rusqlite::params![agent_id],
|
||||
|row| row.get(0),
|
||||
).expect("Failed to query agent profile");
|
||||
|
||||
let current_profile: i64 = test_db
|
||||
.conn
|
||||
.query_row(
|
||||
"SELECT sandbox_profile_id FROM agents WHERE id = ?1",
|
||||
rusqlite::params![agent_id],
|
||||
|row| row.get(0),
|
||||
)
|
||||
.expect("Failed to query agent profile");
|
||||
|
||||
assert_eq!(current_profile, standard_id, "Profile should be updated");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user