Simulation Command

The arc sim command allows you to simulate the potential impact of code changes before merging them. It analyzes your changes, runs tests in a sandbox environment, and provides insights into how they might affect your system.

Usage

arc sim <subcommand> [options]

Subcommands

run

Run a simulation on the current changes.

arc sim run [options]

history

Show the history of previous simulations.

arc sim history [options]

show

Show details of a specific simulation.

arc sim show <simulation_id>

Options for run

OptionDescription
--scenario <scenario>Simulation scenario to run (default: all)
--diff <diff_path>Path to a diff file to simulate (default: current changes)
--branch <branch>Branch to compare against (default: main)
--sandbox <type>Sandbox type: local, docker, e2b (default: local)
--memoryUse memory from previous simulations to improve results
--output <format>Output format: text, json, markdown (default: text)
--save <path>Save simulation results to a file
--debugEnable debug mode

Options for history

OptionDescription
--limit <n>Limit the number of results (default: 10)
--format <format>Output format: text, json, table (default: table)
--service <service>Filter by affected service
--scenario <scenario>Filter by scenario
--risk <min>..<max>Filter by risk score range

Simulation Scenarios

Arc Memory supports the following simulation scenarios:

ScenarioDescription
network_latencySimulates the impact on network latency
memory_usageSimulates the impact on memory usage
cpu_usageSimulates the impact on CPU usage
disk_ioSimulates the impact on disk I/O
error_ratesSimulates the impact on error rates
securityAnalyzes potential security implications
dependenciesAnalyzes impact on dependencies
allRuns all available scenarios

Examples

Basic Simulation

arc sim run

This will run a simulation on your current changes against the main branch.

Specific Scenario

arc sim run --scenario network_latency

This will run only the network latency simulation.

Using a Different Branch

arc sim run --branch develop

This will compare your changes against the develop branch.

Using Memory

arc sim run --memory

This will use insights from previous simulations to improve the results.

Viewing Simulation History

arc sim history

This will show a table of your recent simulations.

Filtering History

arc sim history --service auth-service --scenario network_latency

This will show only simulations that affected the auth-service and ran the network_latency scenario.

Viewing Specific Simulation

arc sim show sim_abc123

This will show detailed results for the simulation with ID sim_abc123.

Output Format

The simulation results include:

  1. Summary: An overview of the simulation, including risk score and affected services
  2. Detailed Analysis: In-depth analysis of potential impacts
  3. Metrics: Quantitative metrics showing predicted changes
  4. Recommendations: Suggestions for mitigating potential issues

Example output:

Simulation Results: sim_abc123
Date: 2023-05-15 14:30:45

Summary:
- Risk Score: 35/100 (Moderate)
- Affected Services: auth-service, api-gateway
- Scenarios: network_latency, memory_usage

Detailed Analysis:
The changes to the authentication middleware could increase latency by
approximately 15-20ms for authentication requests. This is primarily due
to the additional validation step added in auth_middleware.py.

Memory usage is expected to increase by about 5MB per instance due to
caching of validation results.

Metrics:
- Network Latency: +15-20ms for auth requests
- Memory Usage: +5MB per instance
- CPU Usage: No significant change
- Error Rates: No significant change

Recommendations:
1. Consider implementing a more efficient validation algorithm
2. Add monitoring for auth request latency after deployment
3. Verify memory usage in staging environment before production deployment

Sandbox Environments

Arc Memory supports different sandbox environments for running simulations:

EnvironmentDescription
localRuns in a local sandbox with limited isolation
dockerRuns in a Docker container for better isolation
e2bRuns in an E2B cloud sandbox for maximum isolation and reproducibility

Troubleshooting

Simulation Fails to Start

If the simulation fails to start:

  1. Check if you have the necessary permissions
  2. Verify that the sandbox environment is properly configured
  3. Check if there are any syntax errors in your changes
  4. Run with --debug for more detailed error information

Inaccurate Results

If you believe the simulation results are inaccurate:

  1. Try running with a different sandbox environment
  2. Ensure your local environment has all dependencies installed
  3. Run with --memory to leverage insights from previous simulations
  4. Check if the test coverage is sufficient for your changes

See Also