Skip to content

[OMEGA-492] Redo an interrupted memory copy when a container holds omega-memory - #388

Open
TossSky wants to merge 11 commits into
singnet:patch-to-v0.1.20from
sassless:OMEGA-492-volume-in-use
Open

TossSky wants to merge 11 commits into
singnet:patch-to-v0.1.20from
sassless:OMEGA-492-volume-in-use

Conversation

@TossSky

@TossSky TossSky commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

If the copy from omegaclaw-memory did not finish, the next start deletes the partly copied omega-memory volume and copies again. Docker does not delete a volume that a container uses, even a stopped one, so on patch-to-v0.1.20 that start stops with "volume is in use" and "Could not remove the partly copied volume omega-memory". Two kinds of containers can hold the volume at that point. One is a copy container that keeps running after the launcher is killed, for example by SIGHUP when its terminal closes. The other is an omega container, left by start --memory-import on v0.1.20 or started by hand.

Changes in scripts/omega

  • remove_partly_copied_memory first removes the copy containers that use the partly copied volume. They now carry the omega.memory-migration label, so start can tell them from other containers.
  • If any container other than omega still uses the volume, start stops, names it and prints the docker rm -f command. Nothing else is removed, and omega stays.
  • Otherwise start removes omega if it exists, prints "Removed container omega, it used the partly copied volume omega-memory" and deletes the volume. A plain start already removes omega right after the migration step, so only the order changes.
  • --memory-import after an interrupted copy deletes the partly copied volume the same way and clears .migration-started in omegaclaw-memory. Before, the import skipped the migration and kept the marker, so every later plain start treated the imported memory as a partial copy.

Known limits

  • Copy containers started by the v0.1.20 launcher have no label. start names them and does not remove them.
  • If memory was imported over an interrupted copy with v0.1.20, the marker is still there. The first plain start with this change sees that omega-memory is not a partial copy, stops, and prints how to keep it or copy it again.
  • --memory-import after an interrupted copy starts from a new volume in every import mode, because the partial copy is dropped. If that import fails, the next start does not copy omegaclaw-memory again, the same as after an import with no earlier copy.

Testing

  • The fake docker in tests/test_omega_launcher_migration.py now records the volumes and labels of each container. 14 new test cases (lines 443-553 and 603-648) cover the cases above, and 11 of them fail with the launcher from patch-to-v0.1.20.
  • Live runs with singularitynet/omega:v0.1.20 on Docker 29.4.3:
    • With an interrupted copy and a stopped omega container, start on patch-to-v0.1.20 fails with "volume is in use". With the change it removes omega and copies again, history.metta in omega-memory matches omegaclaw-memory, and the omega container starts. A running omega container gives the same result.
    • When the launcher is killed with SIGHUP during the copy and start runs again while the copy container still works, patch-to-v0.1.20 fails with "volume is in use". With the change the copy container is removed and the copy is redone.
    • A leftover copy container that is paused, or still running after the launcher was killed with SIGKILL, is removed and the copy is redone.
    • When a container without the label uses omega-memory, start stops and names it. The volume, the markers and a running omega container stay as they were. After docker rm -f of that container the next start copies.
    • After --memory-import with an exported archive over an interrupted copy, the partly copied volume is replaced and the import completes. The next plain start keeps the imported memory and copies nothing.
    • When omega-memory holds memory that is not a partial copy over an interrupted copy, start stops and leaves the volume and the stopped omega container as they were. Each of the two printed commands works: one keeps the memory, the other copies omegaclaw-memory again. A partly copied history.metta is still copied again.
    • SIGINT during the copy, SIGKILL of the launcher together with its copy container, and a first copy from scratch work as before.

@TossSky
TossSky requested a review from timur-ashkenov October 9, 2026 02:59
@TossSky TossSky closed this Oct 9, 2026
@TossSky TossSky reopened this Oct 9, 2026
@TossSky TossSky closed this Oct 9, 2026
@TossSky TossSky reopened this Oct 9, 2026
Comment thread scripts/omega
echo "Could not remove the partly copied volume ${new_volume}" >&2
return 1
fi
remove_partly_copied_memory "${new_volume}" "${new_container}" "${migration_label}" || return 1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we check whether memory was successfully imported after the interrupted migration, or preserve the existing volume before deleting it? A stale .migration-started marker could otherwise cause a normal start to discard valid imported memory. I see this is documented under Known limits - is this behavior intentional within the scope of OMEGA-492, or should we handle it here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we check whether memory was successfully imported after the interrupted migration, or preserve the existing volume before deleting it?

Done in 7263f93. The copy goes entry by entry, so a partial copy leaves history.metta empty, missing, or a prefix of the old file. Before redoing the copy, start compares the two files. If omega-memory holds anything else, such as an imported archive, start stops, leaves the volume and the omega container as they are, and prints two commands: one clears the marker and keeps the memory, the other removes omega-memory so the copy runs again.

On singularitynet/omega:v0.1.20 both commands work, and a partly copied history is still copied again. The new cases are in d4f1da4.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that covers the case where history has changed. What about --only-vector, where imported vector memory may change while history.metta stays the same?

Comment thread scripts/omega Outdated
if ! old_state=$(docker run --rm --label "${migration_label}" --entrypoint sh --volume "${old_volume}:/from:ro" "${image}" \
-c "if [ -e /from/${marker} ]; then echo migrated; elif [ -e /from/${started_marker} ]; then echo interrupted; fi"); then
if [ -n "${memory_import_file}" ]; then
return 0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning success here allows the import to proceed without checking or clearing a potentially existing .migration-started marker. If the marker check fails temporarily but the subsequent import succeeds, the next normal start can interpret the imported volume as an interrupted copy and delete it. Can we abort with an actionable error when migration state cannot be determined?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we abort with an actionable error when migration state cannot be determined?

Yes, done in 7263f93. A failed marker read now stops the import with "Could not read the migration markers in omegaclaw-memory", the same way it stops a plain start. The marker can no longer outlive an import. Covered by test_memory_import_stops_when_markers_cannot_be_read in d4f1da4.

…able markers on import

- Plain start must keep omega-memory when its history is not a prefix of the old one
- Partly copied or missing history is still copied again
- A memory import stops when the migration markers cannot be read
… on unreadable markers

- Before redoing an interrupted copy, compare history.metta in omega-memory with omegaclaw-memory
- Stop with commands to keep the memory or to copy again when it is not a partial copy
- A memory import no longer skips a failed marker read, so a stale marker cannot remove imported memory later

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants