Skip to main content

Module migration

Module migration 

Source
Expand description

Explicit, repeatable migration between Pi and Ultron sessions (ultron/migration.ts): import_pi_session copies a whole Pi session tree into a new native format-4 session, export_native_session_to_pi writes a native session’s whole tree back as a Pi session (rollback). Nothing here reads Pi’s data directory implicitly: every source path is given by the caller.

Pi entry mapping (Pi entry ids are kept as native entry ids, parents are unchanged):

  • message, compaction, branch_summary, custom -> the native entry of the same type;
  • custom_message -> a native message entry with a custom role message;
  • every other Pi entry type -> a native custom entry pi-session:<type> whose data is the Pi entry without type/id/parentId/timestamp;
  • at the end: the main tip is the Pi leaf, labels are Pi’s resolved labels, the name is Pi’s name, and the main lane configuration carries the model and thinking level Pi resolves at the leaf;
  • a context_edit dominated by its target is baked into the target (replacement or omission); one that only some branches carry is applied per branch on copies (<id>~<editId>, recorded in ultron.pi.copyOf);
  • Pi-reported usage becomes the usage ledger’s imported historical root import:pi:<piSessionId>;
  • an entry the native form cannot reproduce exactly keeps its Pi original in ultron.pi.original.

The native file is byte-for-byte what the TypeScript product writes for the same Pi file (fixtures/migration/migration.json).

Structs§

ExportResult
What an export wrote (ExportNativeSessionToPiResult).
ImportResult
What an import wrote (ImportPiSessionResult).

Enums§

ImportError

Constants§

PI_COPY_OF
PI_ENTRY_CUSTOM_TYPE_PREFIX
PI_LEAF_MARKER_CUSTOM_TYPE
PI_OMITTED_MESSAGE_CUSTOM_TYPE
PI_ORIGINAL

Functions§

export_native_session_to_pi
exportNativeSessionToPi: the native session at session_path (in <sessionsRoot>/<cwd-dir>/) written whole as a Pi session at output_path, which must not exist. Pi resumes at its last entry, the native main tip; labels, the name, and the main lane’s model and thinking level that differ from what the entries say are appended after it.
import_pi_session
importPiSession: the whole tree of the Pi session at pi_session_path as a new native session under sessions_root (entry ids, parents and timestamps kept; the main tip is the Pi leaf). A failed import leaves no session file behind.
import_pi_session_with
import_pi_session with a hook before each commit.
native_session_id_for_pi_session
nativeSessionIdForPiSession: a UUID-shaped (version 8) digest of the Pi session id.
pi_import_usage_root

Type Aliases§

CommitHook
Called before each commit of an import with its 1-based number; an error fails that commit (the TypeScript tests make session.mutate fail the same way).