--- name: omp-worktree-path-gotchas description: "Use in ~/.omp (or any multi-worktree repo) when an edit lands in the wrong checkout, git checkout is policy-refused, or an omp session id is needed — relative-path tool resolution, shared-worktree branch law, session-id lookup, edit auto-prefix trap." --- # Multi-worktree gotchas in ~/.omp-style repos Measured 2026-10-18 building PR #12/#14 in `dank/command-center` worktrees. ## 1. Relative paths resolve to the SESSION worktree — always edit by absolute path `edit`/`read`/`write` with a relative `path` resolve against the session CWD (the harness worktree you were spawned in), NEVER the worktree you `cd`'d into via bash. Identical file content in sibling worktrees yields identical `[path#tag]` hashes, so an edit can "succeed" against the WRONG checkout with no warning; only a rejected stale-hash edit reveals it. - When working in a second worktree, ALL file-tool paths: absolute. - Symptom seen: edit rejected "hash #X is not from this session" while the bash-side `git status` showed the file clean — two different files, two worktrees. Recovery: revert the stray edit (CUT the inserted lines) in the wrong tree, re-read the right tree, redo with absolute header. ## 2. Branching: shared worktrees refuse git checkout Workspace policy blocks `git checkout` (branch switches AND `--` discards) in harness-managed worktrees — concurrent agents depend on them. To start a branch off fresh trunk: ```bash git -C ~/.omp worktree add -q -b /- ~/.omp/wt/ origin/main ``` Never force past the refusal; the new-worktree route is strictly safer. Custom worktrees not matching `wt/wt-*` are invisible to the live-sync reaper — prune them by hand after merge (`git worktree remove`, `git branch -d`). ## 3. omp session id for attribution footers Fleet law requires `session:` in issue/PR bodies. Authoritative source: `~/.omp/agent/sessions//_.jsonl` — the `` is the session id. Pick the newest file whose first `{"type":"title"}` line names this conversation to prove the id is yours. The `wt/-` dir suffix is NOT the session id (it persists across sessions per cwd). ## 4. edit-tool auto-prefix trap (recurring) A body row written bare (intending it as the "original line" anchor or as context) is AUTO-PREFIXED with `+` and INSERTED — leaving the old line plus a duplicate. `PUT n.=n:` therefore behaves like insert, not replace, whenever the anchor row lacks an explicit marker. After any `PUT` where the response warns "Auto-prefixed bare body row(s)", immediately `CUT` the stale line number shown in the response (descending order for multiple CUTs).