Skip to content

Commit 998ce1b

Browse files
committed
feat(forge): add dynamic agent orchestration system for code validation
This introduces the Forge Orchestration System, a comprehensive framework for code validation through dynamically loaded agents. Key features: - Dynamic agent loading from TOML configuration files - DAG-based agent execution with dependency resolution - Three built-in agents: SecurityAgent, QualityAgent, AggregatorAgent - DynamicAgent for user-defined validation rules - /forge slash command with subcommands (run, status, config, agents, check) - ForgeView TUI dashboard for validation monitoring - JSON protocol for structured validation results Architecture: - Agents loaded from .cortex/forge/agents/<agent>/rules.toml - Global config in .cortex/forge/forge.toml - No hardcoded agent definitions - fully configurable - ValidationAgent trait for custom agent implementation Files: - src/cortex-agents/src/forge/ - Core orchestration modules - src/cortex-engine/src/commands/forge.rs - Slash command - src/cortex-tui/src/views/forge.rs - TUI dashboard - .cortex/forge/ - Configuration files
1 parent e0adfe2 commit 998ce1b

23 files changed

Lines changed: 7426 additions & 16 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Aggregator Agent Rules Configuration
2+
3+
[agent]
4+
id = "aggregator"
5+
name = "Result Aggregator"
6+
description = "Collects and summarizes all validation results"
7+
enabled = true
8+
# Always runs last
9+
priority = -1
10+
11+
[thresholds]
12+
# Maximum allowed errors before blocking
13+
max_errors = 0
14+
# Maximum allowed warnings
15+
max_warnings = 10
16+
# Require all agents to pass
17+
require_all_pass = true
18+
19+
[actions]
20+
# What to do when validation passes
21+
on_pass = "proceed"
22+
# What to do when validation fails
23+
on_fail = "block"
24+
# Generate summary report
25+
generate_report = true
26+
report_format = "markdown"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Quality Agent Rules Configuration
2+
3+
[agent]
4+
id = "quality"
5+
name = "Code Quality Validator"
6+
description = "Enforces code quality standards and best practices"
7+
enabled = true
8+
9+
[rules.todo_comments]
10+
enabled = true
11+
severity = "warning"
12+
description = "Find TODO/FIXME/HACK comments"
13+
patterns = ["TODO", "FIXME", "XXX", "HACK"]
14+
max_allowed = 0
15+
16+
[rules.unimplemented_code]
17+
enabled = true
18+
severity = "error"
19+
description = "Detect unimplemented!() and todo!() macros"
20+
21+
[rules.error_handling]
22+
enabled = true
23+
severity = "warning"
24+
description = "Check for unwrap() without context"
25+
allow_in_tests = true
26+
27+
[rules.dead_code]
28+
enabled = false # Often handled by compiler
29+
severity = "info"
30+
description = "Detect potentially unused code"
31+
32+
[rules.documentation]
33+
enabled = true
34+
severity = "info"
35+
description = "Check for missing documentation on public items"
36+
require_module_docs = true
37+
require_function_docs = true
38+
min_doc_length = 10
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Security Agent Rules Configuration
2+
3+
[agent]
4+
id = "security"
5+
name = "Security Validator"
6+
description = "Checks for security vulnerabilities and best practices"
7+
enabled = true
8+
9+
[rules.secrets_exposed]
10+
enabled = true
11+
severity = "error"
12+
description = "Detect hardcoded secrets and API keys"
13+
patterns = [
14+
"(?i)(api[_-]?key|apikey)\\s*[=:]\\s*['\"][^'\"]{8,}['\"]",
15+
"(?i)(secret|password|passwd|pwd)\\s*[=:]\\s*['\"][^'\"]+['\"]",
16+
"(?i)(token|bearer)\\s*[=:]\\s*['\"][^'\"]{16,}['\"]",
17+
]
18+
exclude_patterns = ["*.test.rs", "*_test.go", "*.spec.ts"]
19+
20+
[rules.dependencies_audit]
21+
enabled = true
22+
severity = "warning"
23+
description = "Check for known vulnerable dependencies"
24+
check_cargo_lock = true
25+
check_package_lock = true
26+
27+
[rules.unsafe_code]
28+
enabled = true
29+
severity = "warning"
30+
description = "Detect unsafe blocks without safety comments"
31+
require_safety_comment = true
32+
allowed_files = ["src/ffi/*.rs", "src/sys/*.rs"]
33+
34+
[rules.input_validation]
35+
enabled = true
36+
severity = "info"
37+
description = "Check for proper input validation patterns"

.cortex/forge/forge.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Forge Orchestration Configuration
2+
3+
[global]
4+
# Maximum parallel agent executions
5+
max_parallel = 4
6+
# Timeout for each agent in seconds
7+
timeout_seconds = 300
8+
# Stop on first failure
9+
fail_fast = false
10+
# Output format: "json", "text", "markdown"
11+
output_format = "json"
12+
13+
[agents.security]
14+
enabled = true
15+
priority = 10
16+
17+
[agents.quality]
18+
enabled = true
19+
priority = 10
20+
21+
[agents.aggregator]
22+
enabled = true
23+
depends_on = ["security", "quality"]
24+
priority = 5

Cargo.lock

Lines changed: 24 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cortex-agents/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ tokio = { workspace = true }
1212
serde = { version = "1", features = ["derive"] }
1313
serde_json = "1"
1414
serde_yaml = "0.9"
15+
toml = { workspace = true }
1516
async-trait = "0.1"
17+
async-recursion = "1"
1618
tracing = "0.1"
1719
thiserror = "1"
1820
uuid = { version = "1", features = ["v4"] }

0 commit comments

Comments
 (0)