feat(local-service): allow exact worktree migration

This commit is contained in:
DCCONSTRUCTIONS
2026-08-30 23:23:36 +03:00
parent 2a5763d3fb
commit 177be8869f
5 changed files with 421 additions and 25 deletions
@@ -72,6 +72,49 @@ waits until `bootout` has fully removed the old label, bootstraps the new
declaration and accepts only the exact Mission Core health document. Any
failure restores the previous plist and repeats the same health acceptance.
### Explicit worktree migration
A plan from a different checkout is rejected by default. To migrate the
canonical service between these two exact worktrees, authorize the installed
predecessor explicitly on both plan and apply:
```bash
cd /Users/dcconstructions/Downloads/mnt/NODEDC/NODEDC_MISSION_CORE_m5_observatory
uv run python scripts/manage_mission_core_launch_agent.py plan \
--repository-root /Users/dcconstructions/Downloads/mnt/NODEDC/NODEDC_MISSION_CORE_m5_observatory \
--expected-current-repository-root /Users/dcconstructions/Downloads/mnt/NODEDC/NODEDC_MISSION_CORE
```
The plan is admissible only when `current_working_directory` is exactly
`/Users/dcconstructions/Downloads/mnt/NODEDC/NODEDC_MISSION_CORE`,
`desired_working_directory` is exactly
`/Users/dcconstructions/Downloads/mnt/NODEDC/NODEDC_MISSION_CORE_m5_observatory`
and `changes.repository_migration` is `true`. The same plan must report
`preserved_data_directory` and `changes.preserved_data_directory` as exactly
`/Users/dcconstructions/Downloads/mnt/NODEDC/NODEDC_MISSION_CORE/.runtime/mission-core`,
with `changes.data_directory_preserved=true`. The desired plist then carries
that exact path as `MISSIONCORE_DATA_DIR`; an already configured nonblank,
private canonical `MISSIONCORE_DATA_DIR` is retained instead. Copy the two
exact hashes from that same output:
```bash
uv run python scripts/manage_mission_core_launch_agent.py apply \
--repository-root /Users/dcconstructions/Downloads/mnt/NODEDC/NODEDC_MISSION_CORE_m5_observatory \
--expected-current-repository-root /Users/dcconstructions/Downloads/mnt/NODEDC/NODEDC_MISSION_CORE \
--expected-current-sha256 <current-sha256> \
--expected-desired-sha256 <desired-sha256>
```
The migration option is not a general cross-repository override. The planner
resolves it to one exact path and rejects any installed `WorkingDirectory`
that differs. Apply recomputes the same path-bound plan and still requires both
plist hashes, so a changed predecessor or candidate must be planned again.
Do not symlink either worktree's `.runtime/mission-core` to the other. The
checkout-local singleton lock requires a real private directory; durable data
continuity is expressed only by the path-bound `MISSIONCORE_DATA_DIR` in this
migration plan.
Read-only status:
```bash