|
| 1 | +# Migration Continuity |
| 2 | + |
| 3 | +## Purpose |
| 4 | + |
| 5 | +This document defines the conceptual migration contract governing how Igor transfers execution continuity between nodes. It formalizes migration guarantees, overlap constraints, and failure safety invariants. |
| 6 | + |
| 7 | +This document does NOT prescribe wire formats, serialization schemas, cryptographic mechanisms, or distributed consensus protocols. |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## Terminology |
| 12 | + |
| 13 | +| Term | Definition | |
| 14 | +|------|-----------| |
| 15 | +| **identity** | Canonical logical execution identity of an agent. Uniquely identifies an agent across all nodes and across time. | |
| 16 | +| **authority** | The right held by exactly one node to advance an agent's checkpoint state. Authority is a runtime concept, separate from state durability. | |
| 17 | +| **checkpoint** | Atomic durable snapshot of agent state and metadata at a committed boundary. The canonical durability anchor for execution continuity. | |
| 18 | +| **migration** | Transfer of execution continuity — including identity, authority, and checkpoint lineage — from one node to another. | |
| 19 | +| **ticking** | Active execution of an agent's tick function by the authoritative node. A ticking instance is one that may produce side effects and advance state. | |
| 20 | +| **recovery-required** | A safety state entered when the runtime cannot determine unique authority. Execution is halted until authority is unambiguously resolved. | |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## Migration Definition |
| 25 | + |
| 26 | +### MC-1: Migration as Continuity Transfer |
| 27 | + |
| 28 | +Migration transfers execution continuity from a source node to a target node. It is a structured handoff of: |
| 29 | + |
| 30 | +- **Agent identity** — the target inherits the same canonical identity. |
| 31 | +- **Execution authority** — the target becomes the sole ACTIVE_OWNER. |
| 32 | +- **Checkpoint lineage** — the target resumes from the source's last committed checkpoint. |
| 33 | + |
| 34 | +Migration is not cloning, replication, or restart. It is a transfer of a single execution thread across physical boundaries. |
| 35 | + |
| 36 | +### MC-2: Migration Scope |
| 37 | + |
| 38 | +Migration encompasses: |
| 39 | + |
| 40 | +- Authority lifecycle transition (see [OWNERSHIP_AND_AUTHORITY.md](./OWNERSHIP_AND_AUTHORITY.md)). |
| 41 | +- Checkpoint data transfer from source to target. |
| 42 | +- Execution resumption on target from committed checkpoint. |
| 43 | +- Retirement of source node's role for this agent identity. |
| 44 | + |
| 45 | +Migration does not encompass: |
| 46 | + |
| 47 | +- Creation of new agent identities. |
| 48 | +- Modification of checkpoint content. |
| 49 | +- Parallel or speculative execution. |
| 50 | + |
| 51 | +--- |
| 52 | + |
| 53 | +## Safe Migration Guarantees |
| 54 | + |
| 55 | +### MC-3: Checkpoint Lineage Preservation |
| 56 | + |
| 57 | +Migration MUST preserve checkpoint lineage. |
| 58 | + |
| 59 | +The target node resumes from the exact committed checkpoint produced by the source node. The checkpoint chain before and after migration forms a single unbroken sequence. No checkpoint is lost, skipped, modified, or fabricated during migration. |
| 60 | + |
| 61 | +**Relationship:** Enforces EI-3 (checkpoint lineage integrity) and EI-10 (migration checkpoint continuity). |
| 62 | + |
| 63 | +### MC-4: Execution Identity Preservation |
| 64 | + |
| 65 | +Migration MUST preserve execution identity. |
| 66 | + |
| 67 | +The agent identity on the target node is identical to the agent identity on the source node. From the agent's perspective, migration is transparent — execution continues under the same identity with the same state. |
| 68 | + |
| 69 | +**Relationship:** Enforces OA-1 (canonical logical identity). |
| 70 | + |
| 71 | +### MC-5: Single-Authority Guarantee |
| 72 | + |
| 73 | +Migration MUST maintain the single-authority guarantee at all times. |
| 74 | + |
| 75 | +At no point during migration may two nodes simultaneously hold execution authority for the same agent identity. Authority transfer is serialized: the source relinquishes before the target assumes. |
| 76 | + |
| 77 | +**Relationship:** Enforces EI-1 (single active instance), EI-5 (singular authority), and OA-5 (transfer serialization). |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +## Overlap Constraints |
| 82 | + |
| 83 | +### MC-6: Permitted Preparation Activities |
| 84 | + |
| 85 | +During migration preparation — after the target has been identified but before authority transfer — the target node MAY: |
| 86 | + |
| 87 | +- **Load checkpoint data** — receive and store the checkpoint from the source. |
| 88 | +- **Validate state** — verify checkpoint integrity and format. |
| 89 | +- **Prepare environment** — initialize WASM sandbox, allocate resources, pre-load agent binary. |
| 90 | + |
| 91 | +These activities are read-only with respect to agent state. They prepare the target to assume authority but do not constitute execution. |
| 92 | + |
| 93 | +### MC-7: Prohibited Preparation Activities |
| 94 | + |
| 95 | +During migration preparation, the target node MUST NOT: |
| 96 | + |
| 97 | +- **Tick** — execute the agent's tick function. |
| 98 | +- **Produce side effects** — perform any action attributable to the agent's execution. |
| 99 | +- **Mutate durable state** — write new checkpoints, modify existing checkpoints, or alter any persistent state associated with the agent identity. |
| 100 | + |
| 101 | +These prohibitions hold until the target has formally assumed authority (ACTIVE_OWNER state). |
| 102 | + |
| 103 | +**Rationale:** Preparation activities that mutate state or produce side effects would constitute unauthorized execution, violating the single-authority invariant. The target node is a passive recipient until authority transfer completes. |
| 104 | + |
| 105 | +### MC-8: Source Node Constraints During Handoff |
| 106 | + |
| 107 | +After initiating handoff (HANDOFF_INITIATED), the source node MUST NOT: |
| 108 | + |
| 109 | +- Begin new tick executions. |
| 110 | +- Produce new checkpoints beyond the handoff checkpoint. |
| 111 | + |
| 112 | +The source node MAY: |
| 113 | + |
| 114 | +- Complete any in-progress checkpoint operation. |
| 115 | +- Serve checkpoint data to the target. |
| 116 | +- Maintain the agent's durable state until transfer completes. |
| 117 | + |
| 118 | +--- |
| 119 | + |
| 120 | +## Failure Safety Matrix |
| 121 | + |
| 122 | +The following matrix defines invariant outcomes for migration failure scenarios. Each scenario specifies what MUST be true regardless of implementation, not how the failure is handled. |
| 123 | + |
| 124 | +### FS-1: Crash During Migration |
| 125 | + |
| 126 | +**Scenario:** A node crashes during an active migration — either the source or target fails unexpectedly. |
| 127 | + |
| 128 | +**Invariant outcomes:** |
| 129 | + |
| 130 | +- At most one node may tick the agent after recovery. |
| 131 | +- The last committed checkpoint from the verified authority chain is the recovery anchor. |
| 132 | +- If the source crashed after relinquishing authority but the target did not confirm assumption, the agent enters RECOVERY_REQUIRED state. |
| 133 | +- If the source crashed before relinquishing authority, the source retains authority upon restart and may resume from its last committed checkpoint. |
| 134 | +- If the target crashed after assuming authority, the target retains authority upon restart and resumes from the transferred checkpoint. |
| 135 | +- No state fabrication or interpolation is permitted during recovery. |
| 136 | + |
| 137 | +### FS-2: Network Partition During Transfer |
| 138 | + |
| 139 | +**Scenario:** Network connectivity between source and target is lost during authority transfer. |
| 140 | + |
| 141 | +**Invariant outcomes:** |
| 142 | + |
| 143 | +- Neither node may assume the transfer completed unless it received explicit confirmation. |
| 144 | +- If the source cannot confirm target assumption, the agent enters RECOVERY_REQUIRED state. |
| 145 | +- If the target cannot confirm source retirement, the target MUST NOT begin ticking until authority is unambiguously resolved. |
| 146 | +- A partition MUST NOT cause both nodes to independently resume ticking. |
| 147 | +- The last committed checkpoint remains the recovery anchor. |
| 148 | +- Liveness may be lost for the duration of the partition — this is acceptable per safety-over-liveness (EI-6). |
| 149 | + |
| 150 | +### FS-3: Duplicate Migration Attempts |
| 151 | + |
| 152 | +**Scenario:** Multiple migration requests are issued for the same agent identity concurrently or in rapid succession. |
| 153 | + |
| 154 | +**Invariant outcomes:** |
| 155 | + |
| 156 | +- At most one migration may proceed for a given agent identity at any time. |
| 157 | +- Concurrent migration attempts MUST be serialized or rejected. |
| 158 | +- A second migration request while the agent is in HANDOFF_INITIATED or HANDOFF_PENDING state MUST be refused. |
| 159 | +- No migration attempt may bypass the authority lifecycle. |
| 160 | +- If conflicting migration attempts result in ambiguous authority, the agent enters RECOVERY_REQUIRED state. |
| 161 | + |
| 162 | +### FS-4: Stale Checkpoint Restart |
| 163 | + |
| 164 | +**Scenario:** A node attempts to resume an agent from a checkpoint that is not the latest in the authority chain — for example, due to a stale local copy after migration has occurred. |
| 165 | + |
| 166 | +**Invariant outcomes:** |
| 167 | + |
| 168 | +- A node MUST NOT tick an agent unless it holds execution authority for that agent identity. |
| 169 | +- Possession of a checkpoint does not confer authority (EI-4). |
| 170 | +- If a node detects that its checkpoint is not authoritative (e.g., authority has been transferred), it MUST NOT resume the agent. |
| 171 | +- If a stale restart is detected after ticking has begun, the agent MUST enter RECOVERY_REQUIRED state. |
| 172 | +- The authoritative checkpoint chain — not local storage — determines the valid recovery point. |
| 173 | + |
| 174 | +--- |
| 175 | + |
| 176 | +## Failure Safety Summary |
| 177 | + |
| 178 | +| Scenario | Invariant Outcome | |
| 179 | +|----------|-------------------| |
| 180 | +| Source crash before relinquishing | Source retains authority, resumes from checkpoint | |
| 181 | +| Source crash after relinquishing | RECOVERY_REQUIRED until authority resolved | |
| 182 | +| Target crash after assuming | Target retains authority, resumes from checkpoint | |
| 183 | +| Network partition during transfer | RECOVERY_REQUIRED, no dual ticking | |
| 184 | +| Duplicate migration attempts | Serialized or rejected, at most one proceeds | |
| 185 | +| Stale checkpoint restart | Authority check required, no unauthorized ticking | |
| 186 | + |
| 187 | +--- |
| 188 | + |
| 189 | +## Relationship to Other Specifications |
| 190 | + |
| 191 | +This document operationalizes migration-specific guarantees defined in: |
| 192 | + |
| 193 | +- **[EXECUTION_INVARIANTS.md](./EXECUTION_INVARIANTS.md)** — EI-1 (single instance), EI-6 (safety over liveness), EI-8 through EI-10 (migration invariants). |
| 194 | +- **[OWNERSHIP_AND_AUTHORITY.md](./OWNERSHIP_AND_AUTHORITY.md)** — Authority lifecycle states and transfer serialization rules. |
| 195 | + |
| 196 | +The failure safety matrix provides invariant outcomes for scenarios that exercise these contracts under adverse conditions. |
| 197 | + |
| 198 | +--- |
| 199 | + |
| 200 | +## Document Status |
| 201 | + |
| 202 | +**Type:** Phase 0 Runtime Specification |
| 203 | +**Scope:** Conceptual contracts only — no wire formats, serialization, or cryptographic mechanisms. |
| 204 | +**Authority:** Normative for all future implementation of agent migration behavior and failure recovery. |
0 commit comments