Move duplicate work detection before author branch creation, edits, commits, and pushes #400

Closed
opened 2026-07-07 09:34:11 -05:00 by jcwalker3 · 2 comments
Owner

Problem:
The duplicate-PR gate can stop a second PR from being created, but it fires too late. An author session can still duplicate work by claiming an issue, creating a worktree, editing files, committing, and pushing a remote branch before discovering that another session opened a PR for the same issue.

Observed failure:
Issue #395 was selected as apparently eligible. The session created branch feat/issue-395-proof-backed-handoff-claims, implemented the fix, committed e1e76f0, and pushed the branch. At PR creation time, the gate failed closed because concurrent PR #397 already existed for #395. No duplicate PR was created, but duplicate implementation work and branch cleanup debt were still created.

Required behavior:
Duplicate-work detection must happen before:

  • issue claim,
  • branch lock,
  • worktree creation,
  • file edits,
  • commit,
  • branch push,
  • PR creation.

Acceptance criteria:

  1. work_issue preflight checks for open PRs linked to the target issue before any file edits.

  2. work_issue preflight checks for remote branches matching the target issue before any file edits.

  3. work_issue preflight checks for active issue leases/claims before any file edits.

  4. work_issue preflight re-checks linked PRs immediately before commit.

  5. work_issue preflight re-checks linked PRs immediately before branch push.

  6. work_issue preflight re-checks linked PRs immediately before PR creation.

  7. If a concurrent PR appears after work begins but before commit/push, the workflow stops and preserves local work without pushing.

  8. If a concurrent PR appears after commit but before push, the workflow stops and does not push.

  9. If a concurrent PR appears after push but before PR creation, the workflow creates a reconciliation handoff instead of a PR.

  10. Final report must distinguish:

    • duplicate PR prevented,
    • duplicate branch prevented,
    • duplicate commit prevented,
    • duplicate work not prevented.
  11. Tests cover:

    • PR appears before branch creation,
    • PR appears before file edit,
    • PR appears before commit,
    • PR appears before push,
    • PR appears before PR creation,
    • existing remote branch for same issue,
    • active lease for same issue,
    • stale/expired lease takeover.
  12. Documentation updates the work-issue workflow.

Non-goals:

  • Do not delete duplicate branches automatically.
  • Do not force-push over another session’s work.
  • Do not allow create_pr capability to substitute for full work_issue routing.
Problem: The duplicate-PR gate can stop a second PR from being created, but it fires too late. An author session can still duplicate work by claiming an issue, creating a worktree, editing files, committing, and pushing a remote branch before discovering that another session opened a PR for the same issue. Observed failure: Issue #395 was selected as apparently eligible. The session created branch `feat/issue-395-proof-backed-handoff-claims`, implemented the fix, committed `e1e76f0`, and pushed the branch. At PR creation time, the gate failed closed because concurrent PR #397 already existed for #395. No duplicate PR was created, but duplicate implementation work and branch cleanup debt were still created. Required behavior: Duplicate-work detection must happen before: * issue claim, * branch lock, * worktree creation, * file edits, * commit, * branch push, * PR creation. Acceptance criteria: 1. `work_issue` preflight checks for open PRs linked to the target issue before any file edits. 2. `work_issue` preflight checks for remote branches matching the target issue before any file edits. 3. `work_issue` preflight checks for active issue leases/claims before any file edits. 4. `work_issue` preflight re-checks linked PRs immediately before commit. 5. `work_issue` preflight re-checks linked PRs immediately before branch push. 6. `work_issue` preflight re-checks linked PRs immediately before PR creation. 7. If a concurrent PR appears after work begins but before commit/push, the workflow stops and preserves local work without pushing. 8. If a concurrent PR appears after commit but before push, the workflow stops and does not push. 9. If a concurrent PR appears after push but before PR creation, the workflow creates a reconciliation handoff instead of a PR. 10. Final report must distinguish: * duplicate PR prevented, * duplicate branch prevented, * duplicate commit prevented, * duplicate work not prevented. 11. Tests cover: * PR appears before branch creation, * PR appears before file edit, * PR appears before commit, * PR appears before push, * PR appears before PR creation, * existing remote branch for same issue, * active lease for same issue, * stale/expired lease takeover. 12. Documentation updates the work-issue workflow. Non-goals: * Do not delete duplicate branches automatically. * Do not force-push over another session’s work. * Do not allow `create_pr` capability to substitute for full `work_issue` routing.
Author
Owner

Issue #396 produced another duplicate-work race. A work-issue author session selected #396 as apparently open/unclaimed/no-PR, implemented the full change, committed f20e0fc, pushed feat/issue-396-validation-failure-history, and only then failed closed at the PR gate because concurrent PR #409 already existed for #396.

This is the third observed race pattern today:

The duplicate PR gate prevented a second PR, but it did not prevent duplicate implementation work, duplicate branch creation, commit/push debt, or reconciliation work.

Evidence:

Issue #396 produced another duplicate-work race. A work-issue author session selected #396 as apparently open/unclaimed/no-PR, implemented the full change, committed `f20e0fc`, pushed `feat/issue-396-validation-failure-history`, and only then failed closed at the PR gate because concurrent PR #409 already existed for #396. This is the third observed race pattern today: * #76 * #395 * #396 The duplicate PR gate prevented a second PR, but it did not prevent duplicate implementation work, duplicate branch creation, commit/push debt, or reconciliation work. Evidence: * Issue: #396 * Existing PR: #409 @ `71ccbca` * Duplicate branch: `feat/issue-396-validation-failure-history` @ `f20e0fc` * Stop point: PR gate / second lock failed closed * Gap: duplicate detection happened after full implementation and push * Desired wall: detect linked PR/branch/lease before worktree creation, file edits, commit, and push.
jcwalker3 added the status:in-progress label 2026-07-07 10:34:25 -05:00
Author
Owner

Issue claim heartbeat

<!-- gitea-issue-claim-heartbeat:v1 --> **Issue claim heartbeat** - kind: claim - issue: #400 - branch: feat/issue-400-early-duplicate-work-gate - phase: claimed - profile: prgs-author - pr: none - blocker: none - next_action: create worktree and begin implementation
sysadmin removed the status:in-progress label 2026-07-07 15:40:26 -05:00
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Scaled-Tech-Consulting/Gitea-Tools#400