# osmo-tool/pyosmo architecture

> Architecture diagram of the GitHub repository osmo-tool/pyosmo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/osmo-tool/pyosmo
- Repository: https://github.com/osmo-tool/pyosmo

## Overview

##### Main Components Identification

a) Core Engine Layer:
- Model base class (pyosmo/model.py)
- Main configuration handler (pyosmo/config.py)

b) Algorithm Layer:
- Different algorithms available:
- Random Algorithm
- Weighted Algorithm
- Balancing Algorithm

c) End Conditions Layer:
- Various end conditions:
- Length-based
- Time-based
- Step Coverage
- Logical conditions
- Endless execution

d) Error Strategy Layer:
- Different error handling strategies:
- Allow Count
- Always Ignore
- Always Raise
- Ignore Asserts

e) History Management:
- Test case tracking
- History logging components
- Test step logging

##### Interaction Flows

- Model → Core Engine: Test step execution
- Core Engine → Algorithms: Step selection
- Core Engine → End Conditions: Termination checking
- Core Engine → Error Strategy: Error handling
- Core Engine → History: Logging and tracking

##### External Integration Points

Integration with:
- pytest framework
- Offline test generation capability
- Online test execution
- System Under Test (SUT) interface

##### Important Details

- Model Lifecycle Flow:
- Initialization
- Test Generation
- Execution
- Result Recording

- Configuration Points:
- Test End Conditions
- Suite End Conditions
- Algorithm Selection
- Error Handling Strategy

##### Notes for Implementation

- Both online and offline execution paths
- Where randomization occurs
- Extension points for custom implementations
- Where test case generation happens

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Core Engine Layer
    subgraph CoreEngine["Core Engine Layer"]
        OSMO["OSMO Core"]:::core
        Model["Model Base"]:::core
        Config["Configuration Handler"]:::core
    end

    %% Algorithm Layer
    subgraph Algorithms["Algorithm Layer"]
        AlgoBase["Algorithm Base"]:::algo
        Random["Random Algorithm"]:::algo
        Weighted["Weighted Algorithm"]:::algo
        Balancing["Balancing Algorithm"]:::algo
    end

    %% End Conditions Layer
    subgraph EndConditions["End Conditions Layer"]
        ECBase["Base End Condition"]:::endcond
        Length["Length-based"]:::endcond
        Time["Time-based"]:::endcond
        StepCov["Step Coverage"]:::endcond
        Logical["Logical Conditions"]:::endcond
        Endless["Endless Execution"]:::endcond
    end

    %% Error Strategy Layer
    subgraph ErrorStrategy["Error Strategy Layer"]
        ESBase["Base Strategy"]:::error
        AllowCount["Allow Count"]:::error
        AlwaysIgnore["Always Ignore"]:::error
        AlwaysRaise["Always Raise"]:::error
        IgnoreAsserts["Ignore Asserts"]:::error
    end

    %% History Management
    subgraph History["History Management"]
        HistCore["History Core"]:::history
        TestCase["Test Case Tracking"]:::history
        TestStep["Test Step Logging"]:::history
    end

    %% External Integration
    subgraph External["External Integration"]
        Pytest["Pytest Integration"]:::external
        Offline["Offline Test Generation"]:::external
        SUT["System Under Test"]:::external
    end

    %% Relationships
    Model --> OSMO
    Config --> OSMO
    OSMO --> AlgoBase
    AlgoBase --> Random
    AlgoBase --> Weighted
    AlgoBase --> Balancing
    
    OSMO --> ECBase
    ECBase --> Length
    ECBase --> Time
    ECBase --> StepCov
    ECBase --> Logical
    ECBase --> Endless
    
    OSMO --> ESBase
    ESBase --> AllowCount
    ESBase --> AlwaysIgnore
    ESBase --> AlwaysRaise
    ESBase --> IgnoreAsserts
    
    OSMO --> HistCore
    HistCore --> TestCase
    HistCore --> TestStep
    
    OSMO --> External
    
    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef algo fill:#2ecc71,stroke:#27ae60,color:white
    classDef endcond fill:#f1c40f,stroke:#f39c12,color:black
    classDef error fill:#e74c3c,stroke:#c0392b,color:white
    classDef history fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Click Events
    click OSMO "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/osmo.py"
    click Model "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/model.py"
    click Config "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/config.py"
    click AlgoBase "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/algorithm/base.py"
    click Random "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/algorithm/random.py"
    click Weighted "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/algorithm/weighted.py"
    click Balancing "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/algorithm/balancing.py"
    click ECBase "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/end_conditions/base.py"
    click Length "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/end_conditions/length.py"
    click Time "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/end_conditions/time.py"
    click StepCov "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/end_conditions/step_coverage.py"
    click Logical "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/end_conditions/logical.py"
    click Endless "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/end_conditions/endless.py"
    click ESBase "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/error_strategy/base.py"
    click AllowCount "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/error_strategy/allow_count.py"
    click AlwaysIgnore "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/error_strategy/always_ignore.py"
    click AlwaysRaise "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/error_strategy/always_raise.py"
    click IgnoreAsserts "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/error_strategy/ignore_asserts.py"
    click HistCore "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/history/history.py"
    click TestCase "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/history/test_case.py"
    click TestStep "https://github.com/osmo-tool/pyosmo/blob/master/pyosmo/history/test_step_log.py"
    click Pytest "https://github.com/osmo-tool/pyosmo/tree/master/examples/pytest/"
    click Offline "https://github.com/osmo-tool/pyosmo/tree/master/examples/offline_mbt/"
```
