Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

πŸ”– Checkpoint: Edit /workspaces/claude-code-flow/benchmark/src/swarm_benchmark/core/benchmark_engine.py

rUvb1bec0f91f57
diff --git a/benchmark/README_HELLO_WORLD.md b/benchmark/README_HELLO_WORLD.md
new file mode 100644
index 0000000000..9f58b2a5b7
--- /dev/null
+++ b/benchmark/README_HELLO_WORLD.md
@@ -0,0 +1,105 @@
+# Hello World Function Implementation
+
+A simple yet comprehensive hello world function implementation with parameter support, multiple styles, and thorough testing.
+
+## Features
+
+- βœ… Basic hello world functionality
+- βœ… Parameter support with default values
+- βœ… Input validation and sanitization
+- βœ… Multiple greeting styles (formal, casual, enthusiastic, etc.)
+- βœ… Comprehensive test coverage
+- βœ… Both JavaScript and Python implementations
+
+## JavaScript Usage
+
+```javascript
+const { helloWorld, helloWorldAdvanced } = require('./hello_world');
+
+// Basic usage
+console.log(helloWorld()); // "Hello, World!"
+console.log(helloWorld('Alice')); // "Hello, Alice!"
+
+// Advanced usage with styles
+console.log(helloWorldAdvanced('Bob', 'formal')); // "Greetings, Bob."
+console.log(helloWorldAdvanced('Eve', 'casual')); // "Hey Eve!"
+```
+
+### Running JavaScript Tests
+
+```bash
+node hello_world.test.js
+```
+
+## Python Usage
+
+```python
+from hello_world import hello_world, hello_world_advanced
+
+# Basic usage
+print(hello_world()) # "Hello, World!"
+print(hello_world('Alice')) # "Hello, Alice!"
+
+# Advanced usage with styles
+print(hello_world_advanced('Bob', 'formal')) # "Greetings, Bob."
+print(hello_world_advanced('Eve', 'casual')) # "Hey Eve!"
+```
+
+### Running Python Tests
+
+```bash
+python test_hello_world.py
+```
+
+## Available Greeting Styles
+
+- `default` - Standard greeting: "Hello, Name!"
+- `formal` - Formal greeting: "Greetings, Name."
+- `casual` - Casual greeting: "Hey Name!"
+- `enthusiastic` - Enthusiastic greeting: "Hello, Name! πŸŽ‰"
+- `morning` - Morning greeting: "Good morning, Name!"
+- `evening` - Evening greeting: "Good evening, Name!"
+
+## Implementation Details
+
+### Input Validation
+- Automatically converts non-string inputs to strings
+- Trims whitespace from input names
+- Falls back to 'World' for empty or invalid inputs
+
+### Error Handling
+- Gracefully handles null, undefined, and empty values
+- Unknown styles fall back to default greeting
+- Type coercion for non-string parameters
+
+## Test Coverage
+
+Both implementations include comprehensive test suites covering:
+- Default behavior
+- Custom name parameters
+- Edge cases (empty strings, whitespace, null values)
+- Type conversion (numbers, booleans)
+- All greeting styles
+- Fallback behaviors
+
+## Files Structure
+
+```
+benchmark/
+β”œβ”€β”€ hello_world.js # JavaScript implementation
+β”œβ”€β”€ hello_world.test.js # JavaScript tests
+β”œβ”€β”€ hello_world.py # Python implementation
+β”œβ”€β”€ test_hello_world.py # Python tests
+└── README_HELLO_WORLD.md # This documentation
+```
+
+## Development Notes
+
+This implementation was created by a coordinated swarm of AI agents:
+- **TechLead**: Overall coordination and planning
+- **SystemArchitect**: Function design and API structure
+- **MainDeveloper**: Core implementation
+- **QAEngineer**: Test suite development
+- **TechWriter**: Documentation creation
+
+The swarm worked in parallel to deliver a production-ready hello world function with enterprise-level features.
\ No newline at end of file
diff --git a/benchmark/examples/.claude/checkpoints/1754447043.json b/benchmark/examples/.claude/checkpoints/1754447043.json
new file mode 100644
index 0000000000..646592a5cd
--- /dev/null
+++ b/benchmark/examples/.claude/checkpoints/1754447043.json
@@ -0,0 +1 @@
+{"branch": "checkpoint/pre-edit-20250806-022403", "file": "/workspaces/claude-code-flow/benchmark/test_real_integration.py", "timestamp": "2025-08-06T02:24:03Z", "type": "pre-edit", "original_branch": "alpha-88"}
diff --git a/benchmark/examples/.claude/checkpoints/1754447045.json b/benchmark/examples/.claude/checkpoints/1754447045.json
new file mode 100644
index 0000000000..9d60dedfed
--- /dev/null
+++ b/benchmark/examples/.claude/checkpoints/1754447045.json
@@ -0,0 +1 @@
+{"tag": "checkpoint-20250806-022405", "file": "/workspaces/claude-code-flow/benchmark/test_real_integration.py", "timestamp": "2025-08-06T02:24:05Z", "type": "post-edit", "branch": "alpha-88", "diff_summary": " .claude-flow/metrics/system-metrics.json | 216 +++++ benchmark/.claude-flow/metrics/performance.json | 2 +- benchmark/.claude-flow/metrics/system-metrics.json | 38 +- benchmark/.claude-flow/metrics/task-metrics.json | 6 +- benchmark/.claude/checkpoints/1754447010.json | 1 + benchmark/.claude/checkpoints/1754447012.json | 1 + benchmark/ci_performance_integration.py | 754 ----------------- benchmark/compare_optimizations.py | 172 ---- benchmark/continuous_performance_monitor.py | 673 --------------- benchmark/demo_comprehensive.py | 233 ----- benchmark/demo_mle_star.py | 152 ---- benchmark/demo_real_benchmark.py | 219 ----- benchmark/example_usage.py | 249 ------ .../.claude-flow/metrics/agent-metrics.json | 1 + .../examples/.claude-flow/metrics/performance.json | 9 + .../.claude-flow/metrics/task-metrics.json | 10 + benchmark/examples/real_hive_mind_benchmark.py | 0 benchmark/examples/real_integration_results.json | 78 ++ benchmark/examples/real_sparc_benchmark.py | 0 benchmark/examples/real_swarm_benchmark.py | 0 benchmark/hello_world.py | 21 - benchmark/hive-mind-load-test.py | 902 -------------------- benchmark/hive-mind-stress-test.py | 935 --------------------- benchmark/mle_star_benchmark_example.py | 229 ----- benchmark/performance_dashboard.py | 769 ----------------- benchmark/quick_test_integration.py | 44 - benchmark/run-load-tests.py | 479 ----------- benchmark/run_performance_tests.py | 550 ------------ benchmark/run_real_benchmarks.py | 0 benchmark/simple-load-test.py | 322 ------- .../__pycache__/benchmark_engine.cpython-312.pyc | Bin 7620 -> 8413 bytes .../src/swarm_benchmark/core/benchmark_engine.py | 122 ++- benchmark/swarm_performance_suite.py | 840 ------------------ benchmark/test_claude_optimizer.py | 235 ------ benchmark/test_hello_world.py | 33 - benchmark/test_integration.py | 274 ------ benchmark/test_mle_star_integration.py | 225 ----- benchmark/test_real_benchmark_engine.py | 317 ------- benchmark/test_real_benchmarks.py | 0 benchmark/test_real_claude_flow.py | 218 ----- benchmark/test_real_integration.py | 225 +++++ benchmark/test_real_metrics.py | 128 --- benchmark/test_real_simple.py | 104 --- benchmark/test_simple_run.py | 35 - .../conftest.cpython-312-pytest-8.4.0.pyc | Bin 22406 -> 22448 bytes .../tests/integration/quick_test_integration.py | 2 +- .../tests/integration/test_claude_optimizer.py | 2 +- benchmark/tests/integration/test_integration.py | 2 +- .../tests/integration/test_mle_star_integration.py | 4 +- .../integration/test_real_benchmark_engine.py | 4 +- .../tests/integration/test_real_claude_flow.py | 2 +- benchmark/tests/integration/test_real_metrics.py | 2 +- benchmark/tests/integration/test_simple_run.py | 2 +- claude-flow-wiki | 0 54 files changed, 707 insertions(+), 9134 deletions(-) "}
diff --git a/benchmark/hello_world.test.js b/benchmark/hello_world.test.js
new file mode 100644
index 0000000000..350896e90d
--- /dev/null
+++ b/benchmark/hello_world.test.js
@@ -0,0 +1,98 @@
+/**
+ * Test suite for Hello World functions
+ */
+
+const { helloWorld, helloWorldAdvanced } = require('./hello_world');
+
+// Simple test framework (no external dependencies)
+function test(description, fn) {
+ try {
+ fn();
+ console.log(`βœ… ${description}`);
+ } catch (error) {
+ console.error(`❌ ${description}`);
+ console.error(` Error: ${error.message}`);
+ }
+}
+
+function assertEqual(actual, expected) {
+ if (actual !== expected) {
+ throw new Error(`Expected "${expected}" but got "${actual}"`);
+ }
+}
+
+console.log('Testing helloWorld function:\n');
+
+// Basic functionality tests
+test('Should return "Hello, World!" with no parameters', () => {
+ assertEqual(helloWorld(), 'Hello, World!');
+});
+
+test('Should greet by name when provided', () => {
+ assertEqual(helloWorld('Alice'), 'Hello, Alice!');
+});
+
+test('Should handle empty string as default', () => {
+ assertEqual(helloWorld(''), 'Hello, World!');
+});
+
+test('Should handle whitespace-only string as default', () => {
+ assertEqual(helloWorld(' '), 'Hello, World!');
+});
+
+test('Should convert numbers to strings', () => {
+ assertEqual(helloWorld(42), 'Hello, 42!');
+});
+
+test('Should convert boolean to string', () => {
+ assertEqual(helloWorld(true), 'Hello, true!');
+});
+
+test('Should handle null as string', () => {
+ assertEqual(helloWorld(null), 'Hello, null!');
+});
+
+test('Should handle undefined as default', () => {
+ assertEqual(helloWorld(undefined), 'Hello, World!');
+});
+
+test('Should trim whitespace from names', () => {
+ assertEqual(helloWorld(' Bob '), 'Hello, Bob!');
+});
+
+console.log('\nTesting helloWorldAdvanced function:\n');
+
+// Advanced function tests
+test('Should use default style when not specified', () => {
+ assertEqual(helloWorldAdvanced('Charlie'), 'Hello, Charlie!');
+});
+
+test('Should use formal greeting style', () => {
+ assertEqual(helloWorldAdvanced('Diana', 'formal'), 'Greetings, Diana.');
+});
+
+test('Should use casual greeting style', () => {
+ assertEqual(helloWorldAdvanced('Eve', 'casual'), 'Hey Eve!');
+});
+
+test('Should use enthusiastic greeting style', () => {
+ assertEqual(helloWorldAdvanced('Frank', 'enthusiastic'), 'Hello, Frank! πŸŽ‰');
+});
+
+test('Should use morning greeting style', () => {
+ assertEqual(helloWorldAdvanced('Grace', 'morning'), 'Good morning, Grace!');
+});
+
+test('Should use evening greeting style', () => {
+ assertEqual(helloWorldAdvanced('Henry', 'evening'), 'Good evening, Henry!');
+});
+
+test('Should fallback to default for unknown style', () => {
+ assertEqual(helloWorldAdvanced('Ivy', 'unknown'), 'Hello, Ivy!');
+});
+
+test('Should handle both parameters as defaults', () => {
+ assertEqual(helloWorldAdvanced(), 'Hello, World!');
+});
+
+console.log('\n✨ Test suite completed!');
\ No newline at end of file
diff --git a/benchmark/src/swarm_benchmark/core/benchmark_engine.py b/benchmark/src/swarm_benchmark/core/benchmark_engine.py
index c1b8ce9229..b7a4edc536 100644
--- a/benchmark/src/swarm_benchmark/core/benchmark_engine.py
+++ b/benchmark/src/swarm_benchmark/core/benchmark_engine.py
@@ -164,4 +164,123 @@ class BenchmarkEngine:
},
"created_at": result.created_at.isoformat(),
"completed_at": result.completed_at.isoformat() if result.completed_at else None
- }
\ No newline at end of file
+ }
+ async def run_real_benchmark(self,
+ objective: str,
+ strategy: str = "auto",
+ mode: str = "centralized",
+ max_agents: int = 5,
+ timeout: int = 60) -> Dict[str, Any]:
+ """
+ Run a benchmark using real Claude Flow execution.
+
+ Args:
+ objective: The benchmark objective
+ strategy: Swarm strategy
+ mode: Coordination mode
+ max_agents: Maximum number of agents
+ timeout: Timeout in minutes
+
+ Returns:
+ Dictionary with benchmark results
+ """
+ if not self.use_real_executor or not self.real_executor:
+ raise RuntimeError("Real executor not available. Initialize with use_real_executor=True")
+
+ logger.info(f"Running real benchmark: {objective}")
+ logger.info(f"Configuration: {strategy}/{mode}/{max_agents} agents, timeout={timeout}min")
+
+ start_time = datetime.now()
+
+ try:
+ # Create swarm command configuration
+ swarm_config = SwarmCommand(
+ objective=objective,
+ strategy=strategy,
+ mode=mode,
+ max_agents=max_agents,
+ timeout=timeout
+ )
+
+ # Execute real command
+ result = await self.real_executor.execute_swarm_async(swarm_config)
+ end_time = datetime.now()
+
+ # Convert to benchmark result format
+ benchmark_result = {
+ "benchmark_id": f"real-{objective[:20]}-{start_time.strftime('%Y%m%d-%H%M%S')}",
+ "status": "success" if result.success else "failed",
+ "objective": objective,
+ "strategy": strategy,
+ "mode": mode,
+ "max_agents": max_agents,
+ "execution_details": {
+ "success": result.success,
+ "exit_code": result.exit_code,
+ "duration": result.duration,
+ "command": " ".join(result.command)
+ },
+ "tokens": {
+ "input": result.input_tokens,
+ "output": result.output_tokens,
+ "total": result.total_tokens
+ },
+ "agents": {
+ "spawned": result.agents_spawned,
+ "tasks_completed": result.tasks_completed
+ },
+ "tools": {
+ "calls": len(result.tool_calls),
+ "results": len(result.tool_results)
+ },
+ "performance": {
+ "first_response_time": result.first_response_time,
+ "completion_time": result.completion_time
+ },
+ "output_analysis": {
+ "stdout_lines": len(result.stdout_lines),
+ "stderr_lines": len(result.stderr_lines),
+ "errors": len(result.errors),
+ "warnings": len(result.warnings)
+ },
+ "errors": result.errors,
+ "warnings": result.warnings,
+ "started_at": start_time.isoformat(),
+ "completed_at": end_time.isoformat()
+ }
+
+ # Save results
+ await self._save_real_benchmark_results(benchmark_result)
+
+ logger.info(f"Real benchmark completed successfully: {benchmark_result['benchmark_id']}")
+ return benchmark_result
+
+ except Exception as e:
+ logger.error(f"Real benchmark failed: {e}")
+
+ error_result = {
+ "benchmark_id": f"real-error-{start_time.strftime('%Y%m%d-%H%M%S')}",
+ "status": "failed",
+ "objective": objective,
+ "strategy": strategy,
+ "mode": mode,
+ "max_agents": max_agents,
+ "error": str(e),
+ "started_at": start_time.isoformat(),
+ "completed_at": datetime.now().isoformat()
+ }
+
+ return error_result
+
+ async def _save_real_benchmark_results(self, result: Dict[str, Any]):
+ """Save real benchmark results."""
+ output_dir = Path(self.config.output_directory)
+ output_dir.mkdir(exist_ok=True)
+
+ # Save as JSON
+ import json
+ json_file = output_dir / f"{result['benchmark_id']}.json"
+ with open(json_file, 'w') as f:
+ json.dump(result, f, indent=2)
+
+ logger.info(f"Saved real benchmark results: {json_file}")