Skip to content

feat: structured conflict resolution protocol with hold mechanism #14

@justinjdev

Description

@justinjdev

Summary

Add a structured conflict resolution protocol for when Palantir detects file conflicts between quests, backed by a CLI-enforced "hold" mechanism.

Problem

Palantir detects when two quests touch the same file and sends an alert, but there's no playbook for what happens next. Gandalf has to improvise, and the user often has to manually intervene. There's also no way to reliably pause a quest — prompt-based "please stop" messages are soft enforcement.

Proposed Solution

Hold Mechanism (CLI)

New CLI commands:

  • fellowship hold --dir <worktree> — sets held: true in the quest's state file
  • fellowship unhold --dir <worktree> — clears the hold

Hook enforcement:

  • Extend the existing gate-guard hook (or add a new hold-guard hook) to block Edit/Write/Bash tools when held: true
  • Same pattern as gate blocking — exit code 2, message to stderr explaining why the quest is held
  • Hold is independent of gates — a quest can be held mid-phase

State file addition:

{
  "held": false,
  "held_reason": null
}

Conflict Resolution Protocol (Gandalf's playbook)

When Palantir raises a file conflict alert, Gandalf follows this protocol:

  1. Pausefellowship hold --dir <later-quest-worktree> with reason indicating the conflict
  2. Assess — Read both quests' plans to determine conflict type:
    • Real conflict: both quests modify the same function/section
    • Incidental overlap: different parts of the same file
  3. Resolve — Pick one of three strategies:
    • Sequence: Let the earlier quest finish first, then rebase the later quest's worktree
    • Partition: Assign non-overlapping regions of the file to each quest, update plans
    • Merge: Let both proceed (for incidental overlaps), structured merge at Review phase
  4. Resumefellowship unhold --dir <worktree> with updated instructions via SendMessage

Where This Lives

  • Hold/unhold: CLI commands + hook enforcement (structural)
  • Resolution protocol: embedded in the /fellowship skill (Gandalf's instructions), not a separate skill
  • Palantir's role unchanged — detect and alert only

Key Design Decisions

  • Structural enforcement over prompt-based — consistent with gate philosophy
  • Hold is independent of gates — can pause a quest at any point, not just at phase boundaries
  • Gandalf mediates — resolution strategy is a judgment call, not automated
  • Rebase support — for the "sequence" strategy, could add fellowship rebase --dir <worktree> to automate the worktree rebase after the first quest merges (escalate to user on conflicts)

Prerequisites

Scope

  • CLI: ~100-150 lines (hold/unhold commands + hook logic)
  • Skill updates: additions to /fellowship SKILL.md for Gandalf's conflict protocol
  • Hook updates: extend hooks.json to cover hold-guard

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions