Skip to content

feat(loop-worktree): manage isolated git worktrees per fix attempt#190

Merged
cobusgreyling merged 1 commit into
cobusgreyling:mainfrom
KhaiTrang1995:feat/loop-worktree
Jul 7, 2026
Merged

feat(loop-worktree): manage isolated git worktrees per fix attempt#190
cobusgreyling merged 1 commit into
cobusgreyling:mainfrom
KhaiTrang1995:feat/loop-worktree

Conversation

@KhaiTrang1995

Copy link
Copy Markdown
Contributor

Summary

Closes the prose-only "Worktrees" gap. LOOP.md and docs/primitives.md describe
"one worktree per fix; discard after verifier REJECT or human escalation", and
loop-audit already scores worktree evidence -- but nothing created, tracked, or
swept them. This is the missing code.

What

New package @cobusgreyling/loop-worktree:

  • create -- git worktree add -b loop/<id> .loop-worktrees/<id> <base>,
    recorded in .loop-worktrees/manifest.json
  • mark -- set an entry's status (active|rejected|escalated|merged|stale)
  • cleanup -- remove rejected/escalated worktrees and prune the manifest;
    skips a dirty worktree unless --force
  • gc -- reconcile git worktree list against the manifest (report-only;
    --force removes orphans)
  • list -- human or --json

Registered in root test:tools/build:tools, the README tool table, and
docs/primitives.md.

Why this shape

Independent of loop-context -- no ledger coupling. A loop pairs the two with a
loop-worktree mark --status escalated call in its escalation path, matching
the repo's "independent packages, wire at the edges" convention.

Scope

MVP. Advisory lock/unlock is intentionally deferred to a follow-up, since a
lock keys on the same path/branch a worktree does and is cleaner to layer on
once this exists.

Tested

8 tests over a real git fixture: create/mark/cleanup/gc round-trip, the
dirty-worktree safety skip (no delete without --force), and the not-a-repo /
duplicate-id errors. tsc clean; CLI smoke-tested end to end.

LOOP.md and docs/primitives.md describe "one worktree per fix; discard after
verifier REJECT or human escalation" in prose, but nothing created, tracked, or
swept them. loop-audit even scores worktree evidence yet had no tool to produce
it. This adds the missing code.

New package @cobusgreyling/loop-worktree:
- create  - git worktree add -b loop/<id> .loop-worktrees/<id> <base>,
            recorded in .loop-worktrees/manifest.json
- mark    - set an entry's status (active|rejected|escalated|merged|stale)
- cleanup - git worktree remove for rejected/escalated entries, then prune the
            manifest; skips dirty worktrees unless --force
- gc      - reconcile git worktree list against the manifest (report-only;
            --force removes orphans)
- list    - human or --json output

Stays independent of loop-context (no ledger coupling); pairs via a
`mark --status escalated` call in the loop's escalation path.

Registered in root test:tools/build:tools and the README tool table; wired into
docs/primitives.md #2. 8 tests over a real git fixture cover the
create/mark/cleanup/gc round-trip, the dirty-worktree safety skip, and the
not-a-repo / duplicate-id errors.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Thanks @KhaiTrang1995 for contributing a docs improvement — visible, reviewable PRs like this grow the reference for everyone.

What happens next

  • Maintainer aims for same-day review on story, adopter, and scoped docs/example PRs (CONTRIBUTING.md).
  • good first issue PRs: comment on the linked issue so we can assign and close on merge.

More ways to help

— loop-engineering maintainers

@cobusgreyling
cobusgreyling merged commit 3eac4e7 into cobusgreyling:main Jul 7, 2026
3 checks passed
@HighlanderDJ

HighlanderDJ commented Jul 7, 2026 via email

Copy link
Copy Markdown

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.

3 participants