Skip to content

Class swarmauri_core.programs.IProgram.IProgram

swarmauri_core.programs.IProgram.IProgram

Bases: ABC

Interface for programs under evolution.

This abstract class defines the contract that all evolvable programs must implement, providing methods for comparing, modifying, and validating program representations.

diff abstractmethod

diff(other)

Calculate the difference between this program and another.

PARAMETER DESCRIPTION
other

Another program to compare against

TYPE: IProgram

RETURNS DESCRIPTION
DiffType

A structured representation of the differences between programs

RAISES DESCRIPTION
TypeError

If the other program is not compatible for diffing

Source code in swarmauri_core/programs/IProgram.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@abstractmethod
def diff(self, other: "IProgram") -> DiffType:
    """
    Calculate the difference between this program and another.

    Args:
        other: Another program to compare against

    Returns:
        A structured representation of the differences between programs

    Raises:
        TypeError: If the other program is not compatible for diffing
    """
    pass

apply_diff abstractmethod

apply_diff(diff)

Apply a diff to this program to create a new modified program.

PARAMETER DESCRIPTION
diff

The diff structure to apply to this program

TYPE: DiffType

RETURNS DESCRIPTION
IProgram

A new program instance with the diff applied

RAISES DESCRIPTION
ValueError

If the diff cannot be applied to this program

TypeError

If the diff is not in the expected format

Source code in swarmauri_core/programs/IProgram.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
@abstractmethod
def apply_diff(self, diff: DiffType) -> "IProgram":
    """
    Apply a diff to this program to create a new modified program.

    Args:
        diff: The diff structure to apply to this program

    Returns:
        A new program instance with the diff applied

    Raises:
        ValueError: If the diff cannot be applied to this program
        TypeError: If the diff is not in the expected format
    """
    pass

validate abstractmethod

validate()

Validate that this program is well-formed and executable.

RETURNS DESCRIPTION
bool

True if the program is valid, False otherwise

Source code in swarmauri_core/programs/IProgram.py
50
51
52
53
54
55
56
57
58
@abstractmethod
def validate(self) -> bool:
    """
    Validate that this program is well-formed and executable.

    Returns:
        True if the program is valid, False otherwise
    """
    pass

clone abstractmethod

clone()

Create a deep copy of this program.

RETURNS DESCRIPTION
IProgram

A new program instance with the same state

Source code in swarmauri_core/programs/IProgram.py
60
61
62
63
64
65
66
67
68
@abstractmethod
def clone(self) -> "IProgram":
    """
    Create a deep copy of this program.

    Returns:
        A new program instance with the same state
    """
    pass