Skip to content

Allow assigned-worktree local git merge - #197

Merged
rmems merged 6 commits into
mainfrom
cursor/local-integration-collaboration-65ca
Sep 20, 2026
Merged

rmems merged 6 commits into
mainfrom
cursor/local-integration-collaboration-65ca

Conversation

@rmems

@rmems rmems commented Sep 19, 2026 •

Copy link
Copy Markdown
Owner

User description

Simplification tranche for RM-145 / RM-116. GitHub twins: #1, #39.

Head: e12c2cc3934076766323bda9b1c2071f76db8580 on cursor/local-integration-collaboration-65ca.

Summary

Enable routine local integration and conflict recovery in an assigned feature-branch worktree. Remove the blanket peer-branch merge ban and the bespoke one-shot / never-merge ritual. Do not add a replacement merge-permission engine.

  • git merge on an assigned feature branch is allowlisted (--abort / --continue / --quit remain recovery).
  • Still blocked: git mergetool, merge/pull on main/master, dirty-WIP merge, gh pr merge, auto-merge, merge queue.
  • Guidance (AGENTS.md, SKILL.md, REVIEW.md, CLAUDE.md, README, workflows, ADR, hook-boundary) now describes collaboration-first local integration. GitHub owns remote PR merges.

Tests

  • Two-worktree local-integration regression (two_worktree_local_merge_integrates_peer_branch)
  • Negative WIP-loss case (merge_refuses_to_lose_uncommitted_wip and hook cwd equivalent)
  • Default-branch merge/pull still MERGE_BLOCKED

Native gates on this head: cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace — all passed.

Operator gap (reported, not changed)

Live reads found main.protected=false and no rulesets on rmems/writ. GitHub is still the intended remote-merge authority. This PR does not change repository settings, enable unattended remote merging, or merge a pull request.

Coordination

Linear Issue: RM-145

Open in Web Open in Cursor 

Summary by cubic

Allows git merge in assigned feature-branch worktrees so workers can integrate peer work locally and recover from conflicts; GitHub remains the only place a PR merge can happen. Removes the blanket peer-branch merge ban and the one-shot PR merge protocol. Covers RM-145's local-integration and conflict-recovery goals.

Behavior

  • Still blocked: git mergetool, merge or pull on main/master, dirty-WIP merges, gh pr merge, auto-merge, and merge queues; git pull now hits the same WIP guard as git merge.
  • The hook resolves merge/pull against the effective -C target, folding chained operands, and fails closed for unknown repos, missing event cwd, or --git-dir/--work-tree/--namespace overrides.
  • --abort, --continue, and --quit stay allowed for conflict recovery.
  • writ gains no merge-permission engine and no unattended PR merge path; docs, workflows, the ADR, and hook-boundary docs were updated to match.

Tests and notes

  • Adds two-worktree local-integration and WIP-loss refusal tests at the core and hook levels, with Windows-safe test setup.
  • A live repo check found main.protected=false with no rulesets; the PR reports this gap without changing repository settings.
  • The lease store and its handoff contract are untouched.

Written for commit 4373182. Summary will update on new commits.

Review in cubic


CodeAnt-AI Description

Allow safe local integration of peer branches in assigned feature worktrees

What Changed

  • Clean assigned feature branches can now merge compatible peer branches locally
  • Merges and pulls on main or master, merges with uncommitted work, interactive merge tools, and GitHub pull-request merges remain blocked
  • Merge recovery commands such as abort, continue, and quit remain available
  • Guidance now directs humans and GitHub repository protection to handle remote pull-request merges
  • Added coverage for successful peer-branch integration, default-branch blocks, dirty-worktree protection, and merge recovery

Impact

✅ Faster peer-branch integration
✅ Uncommitted WIP protected from merge loss
✅ GitHub PR merges remain blocked

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Remove the blanket peer-branch merge ban and the one-shot GitHub merge
ritual from AGENTS.md and dependent guidance. Admit git merge on
feature branches while still blocking mergetool, default-branch
integration, dirty-WIP merges, and gh pr merge.

Adds a two-worktree local-integration regression and a negative
WIP-loss case. GitHub remains the remote-merge authority; this does
not enable unattended PR merges.

Refs RM-145, RM-116, #39, #1

Co-authored-by: Raul Cardenas Montoya <montoyaraul34@gmail.com>
@coderabbitai

coderabbitai Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: ab6955e8-d86e-42fb-9eea-7092d37f0825


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@linear-code

linear-code Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

RM-145

Co-authored-by: Raul Cardenas Montoya <montoyaraul34@gmail.com>
codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@codacy-production

codacy-production Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 medium

Alerts:
⚠ 1 issue (≤ 0 issues of at least minor severity)

Results:
1 new issue

Category Results
Complexity 1 medium

View in Codacy

🟢 Metrics 10 complexity · 8 duplication

Metric Results
Complexity 10
Duplication 8

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov

codecov Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.38547% with 19 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/writ-core/src/hook.rs 88.76% 10 Missing ⚠️
crates/writ-core/src/git_safe/mod.rs 87.03% 7 Missing ⚠️
crates/writ-core/src/bash_argv/mod.rs 94.11% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@rmems

rmems commented Sep 19, 2026

Copy link
Copy Markdown
Owner Author

RM-145 same-host consume of #198 (3020744 binary) + #197 (e12c2cc git-safe): two jobs, advisory overlap, dependency inbox, local conflicted merge admitted only by #197, WIP refuse, pause/handoff ACK without WIP loss, gh pr merge still blocked. Not a mashup PR. Cloud SQLite not shared. Live #198 now 07ba398.

Grok.

Set core.autocrlf=false in temp test repos so merged blob contents stay
LF on Windows runners. Extract shared repo-setup and dispatch helpers in
the hook merge tests and a MERGE_BLOCKED assertion helper in git_safe
tests to clear the CodeScene duplication / large-assertion findings.

Co-Authored-By: Raul Cardenas Montoya <montoyaraul34@gmail.com>
codescene-access[bot]

This comment was marked as outdated.

@linear-code
linear-code Bot marked this pull request as ready for review September 20, 2026 00:18
@codeant-ai

codeant-ai Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR 95b277b Sep 20, 2026 · 00:19 00:21

@codeant-ai

codeant-ai Bot commented Sep 20, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@mergify

mergify Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Sep 20, 2026
Comment thread docs/workflows/safe-issue-verified-commit.md Outdated
Comment thread crates/writ-core/src/git_safe/mod.rs Outdated
Comment thread crates/writ-core/src/git_safe/mod.rs
Comment thread crates/writ-core/src/hook.rs
Comment thread crates/writ-core/src/hook.rs Outdated
Comment thread AGENTS.md
Comment thread AGENTS.md Outdated
@codeant-ai

codeant-ai Bot commented Sep 20, 2026

Copy link
Copy Markdown

CodeAnt Nitpicks

1 code suggestion

1. The dirty-tree check and merge are separate processes, so another process can add uncommitted changes after the check and the merge can then overwrite that WIP.

Race condition · crates/writ-core/src/git_safe/mod.rs:339-348

- git pull on a dirty feature branch now hits the same WIP guard as merge
- the hook resolves merge/pull against an explicit -C target (chained
  operands folded) instead of the event cwd, and fails closed on
  --git-dir/--work-tree/--namespace overrides
- merge/pull with neither an event cwd nor a -C target is refused rather
  than skipping the guards

Co-Authored-By: Raul Cardenas Montoya <montoyaraul34@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

Fixed in 25a32de: admit_local_merge now runs the same dirty-tree WIP guard for pull as for merge — a pull on a dirty feature branch is refused with MERGE_BLOCKED.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Fixed in 25a32de: the pull branch no longer returns before the dirty-tree check — merge and pull now share one code path, so git pull on a dirty feature branch is refused with MERGE_BLOCKED.

codescene-access[bot]

This comment was marked as outdated.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Accurate observation, but out of scope for this tranche: the hook/runtime has no assignment registry to check against — worktree↔job assignment lives in the lease store, which RM-825 owns. writ-core enforces the invariants it can verify (default branch, dirty WIP, bare force); "only the assigned branch" stays a policy-layer rule in AGENTS.md, per the PR's "no replacement merge-permission engine" constraint.

Extract admit_git_invocation (hook) and record_location_global (bash_argv)
to clear the nested-complexity findings on the previous head.

Co-Authored-By: Raul Cardenas Montoya <montoyaraul34@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

Addressed in 93978fe: the paragraph now states the actual enforcement surface — the hook verifies merge/pull against the event cwd (or an explicit -C target) and fails closed when neither is known. Assignment itself remains a policy-layer rule, not a Rust check, since the runtime has no lease/assignment lookup.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Fair caveat — watched.json is read-only and path-scoped lease coordination isn't wired yet (that's RM-825's shared-state contract, which this PR deliberately doesn't re-implement). The sentence is about where visibility should live (don't invent another database), not a claim that it's complete; kept as guidance text.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Acknowledged — the check→merge window is inherent to any pre-command admission. The dirty-tree guard covers the realistic collaborators (peers that commit between admission and merge); a writer racing inside that window surfaces as a merge conflict or a git-ref update failure rather than silent loss, since git refuses to clobber a moved ref without --force (which remains a hard block).

codescene-access[bot]

This comment was marked as outdated.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 15 complexity · 8 duplication

Metric Results
Complexity 15
Duplication 8

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

…ion-collaboration-65ca

Co-Authored-By: Raul Cardenas Montoya <montoyaraul34@gmail.com>

# Conflicts:
#	README.md
#	crates/writ-core/src/hook.rs
#	docs/workflows/safe-issue-verified-commit.md

@codescene-access codescene-access Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gates Passed
6 Quality Gates Passed

See analysis details in CodeScene

Quality Gate Profile: Pay Down Tech Debt
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@rmems
rmems merged commit 37280d1 into main Sep 20, 2026
15 checks passed
cursor Bot pushed a commit that referenced this pull request Sep 21, 2026
…gistry

Integrate #197/#199 (local feature-branch merge admission and harness-owned
checkouts) while preserving `writ ci classify` and the `gh run` allowlist.
No remote merge, no settings change, no empty retrigger commit.

Agent: Cursor Grok 4.6

Co-authored-by: Raul Cardenas Montoya <montoyaraul34@gmail.com>
cursor Bot pushed a commit that referenced this pull request Sep 21, 2026
Bring in harness-owned checkout registration (#199) and assigned-worktree
local merge (#197). Keep attribution.format in the examples table next to
the updated worktree register/list commands.

Agent: Cursor Grok 4.6

Co-authored-by: Grok <noreply@x.ai>
Co-authored-by: Cursor <cursoragent@cursor.com>
@rmems rmems self-assigned this Sep 21, 2026
cursor Bot pushed a commit that referenced this pull request Sep 23, 2026
… admission

Integrate live origin/main (88ac231: status/watchlist, attribution, hang
recovery) while preserving `writ ci classify` and the `gh run` allowlist.
Keep assigned-worktree local merge admission from #197. No remote merge,
no settings change, no empty retrigger commit.

Agent: Cursor Grok 4.6

# Conflicts:
#	README.md
#	crates/writ/src/main.rs
#	docs/status-schema.md

Co-authored-by: Raul Cardenas Montoya <montoyaraul34@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

Development

Successfully merging this pull request may close these issues.

2 participants