migration
migration
¶
Migration support for workspace-local outcomes to global store.
This module implements the migration strategy from Movement III design: - Import existing .marianne-outcomes.json on first use or explicit command - Scan common workspace locations - Run pattern detection on imported data - Preserve workspace-local files (non-destructive)
Migration Flow: 1. On GlobalLearningStore initialization, check if empty 2. Scan common workspace locations for .marianne-outcomes.json 3. For each found, import outcomes to executions table 4. Run pattern detection on imported data 5. Log migration summary to user
Attributes¶
Classes¶
MigrationResult
dataclass
¶
MigrationResult(errors=list(), skipped_workspaces=list(), imported_workspaces=list(), workspaces_found=0, outcomes_imported=0, patterns_detected=0)
Result of a migration operation.
Attributes:
| Name | Type | Description |
|---|---|---|
workspaces_found |
int
|
Number of workspaces with outcomes. |
outcomes_imported |
int
|
Total outcomes imported. |
patterns_detected |
int
|
Patterns detected from imported outcomes. |
errors |
list[str]
|
Any errors encountered during migration. |
skipped_workspaces |
list[str]
|
Workspaces skipped (already imported, etc.). |
imported_workspaces |
list[str]
|
Workspaces successfully imported. |
OutcomeMigrator
¶
Migrates workspace-local outcomes to the global store.
This migrator scans for existing .marianne-outcomes.json files and imports their contents into the global SQLite database, enabling cross-workspace learning from historical data.
Migration is: - Non-destructive: Original files are preserved - Idempotent: Already-imported outcomes are skipped - Pattern-aware: Runs pattern detection after import
Usage
migrator = OutcomeMigrator(global_store) result = migrator.migrate_all() print(f"Imported {result.outcomes_imported} outcomes")
Initialize the outcome migrator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
global_store
|
GlobalLearningStore
|
Global learning store to import into. |
required |
aggregator
|
PatternAggregator | None
|
Optional pattern aggregator for pattern detection. |
None
|
Source code in src/marianne/learning/migration.py
Functions¶
migrate_all
¶
Migrate all discoverable workspace-local outcomes.
Scans standard locations plus any additional paths for .marianne-outcomes.json files and imports them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scan_patterns
|
list[str] | None
|
Glob patterns to scan (defaults to standard locations). |
None
|
additional_paths
|
list[Path] | None
|
Additional specific paths to scan. |
None
|
Returns:
| Type | Description |
|---|---|
MigrationResult
|
MigrationResult with import statistics. |
Source code in src/marianne/learning/migration.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
migrate_workspace
¶
Migrate a single workspace's outcomes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace_path
|
Path
|
Path to the workspace directory. |
required |
Returns:
| Type | Description |
|---|---|
MigrationResult
|
MigrationResult for this workspace. |
Source code in src/marianne/learning/migration.py
Functions¶
migrate_existing_outcomes
¶
Convenience function to migrate all existing outcomes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
global_store
|
GlobalLearningStore
|
Global learning store to import into. |
required |
scan_patterns
|
list[str] | None
|
Optional custom scan patterns. |
None
|
additional_paths
|
list[Path] | None
|
Optional additional paths to scan. |
None
|
Returns:
| Type | Description |
|---|---|
MigrationResult
|
MigrationResult with import statistics. |
Source code in src/marianne/learning/migration.py
check_migration_status
¶
Check the current migration status.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
global_store
|
GlobalLearningStore
|
Global learning store to check. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with migration status information. |