> ## Documentation Index
> Fetch the complete documentation index at: https://docs.galileo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# base

## Module

Base classes for lifecycle and state management.

## SyncState

Enumeration of possible synchronization states for business objects.

## Attributes

LOCAL\_ONLY: Object exists only in memory, not yet persisted remotely.
SYNCED: Local and remote states match.
DIRTY: Local changes exist that have not been saved.
FAILED\_SYNC: Last attempt to sync failed.
DELETED: Object was deleted remotely, local object still exists.

## StateManagementMixin

Base mixin for business objects providing lifecycle state management.

This mixin provides state tracking and helper methods for objects that
need to synchronize between local and remote (API) states.

Subclasses may declare a `_TRACKED_FIELDS` frozenset to enable automatic
dirty-tracking: any assignment to a tracked field on a SYNCED object will
transition it to DIRTY so that callers know a `save()` is needed.

## Attributes

\_sync\_state: Current synchronization state of the object.
\_last\_error: Last error encountered during synchronization (optional).
\_TRACKED\_FIELDS: frozenset of attribute names whose mutations trigger
SYNCED → DIRTY transitions.

### has\_failed

```python theme={null}
def has_failed(self) -> bool
```

Check if the last synchronization attempt failed.

## Returns

bool: True if the last sync failed, False otherwise.

### is\_deleted

```python theme={null}
def is_deleted(self) -> bool
```

Check if the object has been deleted remotely.

## Returns

bool: True if the object was deleted, False otherwise.

### is\_dirty

```python theme={null}
def is_dirty(self) -> bool
```

Check if the object has unsaved local changes.

## Returns

bool: True if the object has unsaved changes, False otherwise.

### is\_local\_only

```python theme={null}
def is_local_only(self) -> bool
```

Check if the object exists only locally.

## Returns

bool: True if the object has not been persisted, False otherwise.

### is\_synced

```python theme={null}
def is_synced(self) -> bool
```

Check if the object is synchronized with the remote state.

## Returns

bool: True if the object is synced, False otherwise.

### refresh

```python theme={null}
def refresh(self) -> None
```

Refresh the object state from the remote API.

This method should:

1. Fetch the latest state from the API
2. Update all local attributes
3. Set the state to SYNCED on success

## Raises

NotImplementedError: If not implemented by subclass.

### sync\_state

```python theme={null}
def sync_state(self) -> SyncState
```

Get the current synchronization state.

## Returns

SyncState: The current state of the object.
