{"record":{"id":"61ee560e609250b4","repo":"nikivdev/code","slug":"sync-agent-cleared-the-raw-stash-conflicts-but-lef","errorCode":null,"errorMessage":"sync agent cleared the raw stash conflicts but left the repo mid-merge.\nRun `:sync repair --packet {}` or inspect the repo before dropping the stash.","messagePattern":"sync agent cleared the raw stash conflicts but left the repo mid-merge\\.\nRun `:sync repair --packet (.+?)` or inspect the repo before dropping the stash\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sync.rs","lineNumber":5244,"sourceCode":"    }\n\n    if let Some(packet_path) = repair_packet_path {\n        if allow_autofix {\n            match try_route_sync_conflicts_to_sync_agent(repo_root, &packet_path)? {\n                SyncRepairRouteOutcome::Completed => {\n                    restore_intent_to_add_paths(repo_root, &auto_stash_state.intent_to_add_paths)\n                        .context(\"restored stash but could not restore intent-to-add markers\")?;\n                    if drop_latest_stash_if_present(repo_root)? {\n                        sync_progressln!(\n                            \"  ✓ Sync agent resolved stash conflicts and dropped auto-stash\"\n                        );\n                    } else {\n                        sync_progressln!(\"  ✓ Sync agent resolved stash conflicts\");\n                    }\n                    return Ok(());\n                }\n                SyncRepairRouteOutcome::ValidationPending => {\n                    bail!(\n                        \"sync agent cleared the raw stash conflicts but left the repo mid-merge.\\nRun `:sync repair --packet {}` or inspect the repo before dropping the stash.\",\n                        packet_path.display()\n                    );\n                }\n                SyncRepairRouteOutcome::Unresolved => {}\n            }\n        }\n        bail!(\n            \"failed to restore sync auto-stash automatically: {}\\nRun `:sync repair --packet {}` or `git stash list` and restore manually if needed.\",\n            detail,\n            packet_path.display()\n        );\n    }\n    bail!(\n        \"failed to restore sync auto-stash automatically: {}\\nRun `git stash list` and restore manually if needed.\",\n        detail\n    );\n}","sourceCodeStart":5226,"sourceCodeEnd":5262,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/sync.rs#L5226-L5262","documentation":"The automated repair agent (Claude-driven repair route) reported it cleared the raw stash conflict markers but the repository is still in a mid-merge state (MERGE_HEAD present / unresolved index entries). The library bails so the user does not drop a stash from a half-finished merge.","triggerScenarios":"`SyncRepairRouteOutcome::ValidationPending` returned after the agent pass: stash conflicts were edited but post-repair validation still detects merge state.","commonSituations":"Agent removed conflict markers from files but never ran `git add`; merge was never committed; leftover MERGE_HEAD from the failed stash pop.","solutions":["Run `:sync repair --packet <path>` to restart the repair flow","Inspect the repo: `git status`, finish or abort the merge (`git merge --abort` if unintended)","After verifying the worktree, manually drop the stash entry"],"exampleFix":"git status          # confirm mid-merge\ngit add -A && git commit   # or: git merge --abort\n:sync repair --packet /tmp/sync-repair-abc123","handlingStrategy":"validation","validationCode":"test mid_merge() {\n    let dirty = std::path::Path::new(\".git/MERGE_HEAD\").exists();\n    assert!(!dirty, \"resolve mid-merge state before dropping stash\");\n}","typeGuard":null,"tryCatchPattern":"if err.contains(\"left the repo mid-merge\") {\n    // abort or complete the merge before any stash drop\n    run(\"git\", &[\"status\"]);\n    // choose: git merge --abort  OR  git add -A && git commit\n}","preventionTips":["Never `git stash drop` while `.git/MERGE_HEAD` exists","After any conflict resolution, always `git add` and verify `git status` is clean","Review agent-produced resolution output instead of trusting success lines","Keep the repair packet path until the repo is verified clean"],"tags":["git","merge","stash","sync-agent"],"backgroundTag":"repo-mid-merge-state","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}