Skip to content

Enforce one agent session per PR branch: require a claim before commit/push #4155

Description

@dem-extra1

What happened (2026-09-30, Pacific)

Two agent sessions worked the same three PR branches at the same time, and neither one claimed them:

The local session found the collision only through the git ls-remote check it ran before pushing. By then, the cloud session's "restore" commit on #4134 (468eef5e) had left memories/preferences.md at 706 lines instead of 1177, dropping 16 sections. The local session stood down and posted its findings (comment).

Maintainer directive: different agent sessions must not work on the same branch at the same time.

Why the existing rule did not prevent it

shared/workflow/claim-pr.md and the claim-pr skill say to claim before working, but nothing enforces it. Both sessions skipped the claim. ListAgents cannot see cloud sessions, so the local session had no other way to discover the peer.

Proposed mechanism

  1. A local PreToolUse hook on git commit and git push in a checkout whose branch has an open PR. It denies the call unless the PR has a claim comment from this session that is newer than any other session's claim. Before a push, it also warns when the branch has pushes from another actor or session since this session's claim; the forge activity endpoint provides that check. The hook would have stopped the local session at its first commit.
  2. A server-side half, because hooks are inert in remote and web sessions (Every PreToolUse and Stop hook is inert in remote/web sessions: the plugin is never installed #2004). One option is a check run or bot that flags a push to a PR branch when the latest claim comment names a different session. The other is to make the cloud agent's own instructions read the claim comments before its first push.

Out of scope here: the #4134 content loss itself, which is reported on that PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions