Skip to content

Make /settle worktree-aware for multi-task hosts - #11

Merged
jucasoliveira merged 2 commits into
masterfrom
claude/ai-standards-multi-agent-tasks-88qrxa
Jul 21, 2026
Merged

Make /settle worktree-aware for multi-task hosts#11
jucasoliveira merged 2 commits into
masterfrom
claude/ai-standards-multi-agent-tasks-88qrxa

Conversation

@jucasoliveira

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #10. Modern agentic hosts (Claude Code, Cursor) develop several changes in parallel, each in its own git worktree. This PR makes the /settle skill and settle CLI first-class citizens of that model.

Design stance: decisions travel with the branch — the record of a change's review commits and merges together with the change it adjudicated — while ledger mutations stay linear on the main checkout.

Changes

Worktree detection (go/settle/worktree.go)

Pure-filesystem GitInfo helper (no git binary dependency): resolves the enclosing checkout, detects linked worktrees via the .git file's gitdir pointer, and parses the current branch (or detached short SHA) from HEAD.

CLI behavior (go/cmd/settle, go/settle)

  • Branch stamping: every panel spec and decision record now carries subject.branch, so reviews made in parallel worktrees identify the branch they belong to; settle log shows it.
  • Conflict-free decision merging: settle init writes .settlement/.gitattributes with decisions.jsonl merge=union — decision logs recorded on parallel branches union-merge instead of conflicting.
  • Ledger linearity guard: settle outcome refuses to run in a linked worktree (with --force as a deliberate escape hatch) — grading happens in the main checkout after merge, so ledger.json history can never diverge across worktrees.

Skill guidance (skill/settle/SKILL.md)

New "Multi-task and worktree hosts" section: run /settle review inside the worktree whose change it judges; branch-scoped task ids (review-<branch>-<date>) so parallel reviews never collide; reviewer subagents are read-only and never need worktrees of their own; one branch = one settlement; grade outcomes only from the main checkout; never settle init inside a worktree.

Tests

  • go/settle/worktree_test.go: main-checkout, linked-worktree, and detached-HEAD detection; a real git init + git worktree add layout end-to-end (skips when git is unavailable); the union-merge attribute written by init.
  • Manual E2E in a scratch repo with a live worktree: tally inside the worktree records branch: task-a; settle outcome there refuses with exit 1.

Verification

🤖 Generated with Claude Code

https://claude.ai/code/session_016Zycxwvy6wPQwiyRSmmJJz


Generated by Claude Code

claude added 2 commits July 21, 2026 12:13
Pure-filesystem GitInfo: resolves the enclosing checkout, detects
linked worktrees via the .git file's gitdir pointer, and parses the
current branch (or detached short SHA) from HEAD. First piece of
making /settle worktree-aware for hosts that run parallel tasks in
git worktrees (Claude Code, Cursor).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Zycxwvy6wPQwiyRSmmJJz
Hosts like Claude Code and Cursor develop parallel changes in git
worktrees; settlement now works with that model:

- Decision records carry the branch under review (Subject.Branch,
  stamped by the CLI from a pure-filesystem GitInfo helper that detects
  linked worktrees and parses HEAD without the git binary).
- settle init writes .settlement/.gitattributes with
  'decisions.jsonl merge=union' so decision logs recorded on parallel
  branches merge without conflicts — reviews travel with the branch
  they judged.
- settle outcome refuses to run in a linked worktree (--force to
  override): ledger history stays linear on the main checkout.
- settle log shows the branch per decision.
- SKILL.md gains a multi-task/worktree section: run reviews inside the
  worktree they judge, branch-scoped task ids, reviewers stay
  read-only, grade outcomes only after merge.

Tests cover main/linked/detached detection (including a real
'git worktree add' layout), the union-merge attribute, and the E2E flow
was verified in a scratch repo with a live worktree.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Zycxwvy6wPQwiyRSmmJJz
@jucasoliveira
jucasoliveira merged commit 1bbcb14 into master Jul 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants