Skip to content

feat: add merge queue with conflict-aware ordering#9

Open
yangwao wants to merge 1 commit intozippoxer:mainfrom
yangwao:feat/merge-queue
Open

feat: add merge queue with conflict-aware ordering#9
yangwao wants to merge 1 commit intozippoxer:mainfrom
yangwao:feat/merge-queue

Conversation

@yangwao
Copy link
Copy Markdown

@yangwao yangwao commented Jan 25, 2026

Summary

Implements a merge queue system for batch merging multiple tasks in optimal order, addressing #6.

  • Three ordering strategies: FIFO, priority-based, and conflict-aware (default)
  • Priority field (P1-P5) added to tasks with --priority flag on draft
  • Conflict detection: identifies overlapping files between tasks
  • Auto-rebase: handles base branch advancement during queue processing
  • Maturity checks: ensures tasks are ready before merging

New Commands

# Show merge queue with ordering
subtask queue list [--strategy fifo|priority|conflict-aware] [--stage ready] [--all]

# Merge ready tasks in queue order  
subtask queue merge [--dry-run] [--stop-on-error] [--no-rebase]

Implementation

File Purpose
pkg/task/queue/queue.go Core types, Build() function
pkg/task/queue/scoring.go Score calculation (priority 50%, age 20%, conflict-free 20%, stage 10%)
pkg/task/queue/conflicts.go Overlap matrix, optimal ordering algorithm
pkg/task/queue/maturity.go Readiness checks
pkg/task/ops/queue.go MergeQueue, AutoRebase operations
cmd/subtask/queue.go CLI commands

Schema v7 migration adds priority column with index.

Test plan

  • All existing tests pass (go test ./... -short)
  • Build succeeds (go build ./cmd/subtask)
  • Manual test: subtask queue list shows empty queue
  • Manual test: subtask queue merge --dry-run works

Closes #6

🤖 Generated with Claude Code

Implement a merge queue system for batch merging multiple tasks in
optimal order. The queue supports three ordering strategies:
- FIFO: oldest first
- Priority: by task priority (P1-P5) then age
- Conflict-aware (default): minimizes cascading conflicts

Key features:
- Priority field (1-5) added to tasks, settable via --priority flag
- Scoring algorithm weighs priority (50%), age (20%), conflict-free (20%), stage (10%)
- Overlap detection identifies tasks modifying same files
- Auto-rebase handles base branch advancement during queue processing
- Maturity checks ensure tasks are ready (open, clean, no conflicts, stage met)

New commands:
- subtask queue list: show ordered merge queue
- subtask queue merge: execute queue with dry-run, stop-on-error options

Schema v7 adds priority column with index for efficient queue queries.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@yangwao yangwao mentioned this pull request Jan 25, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ed5e12e093

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread pkg/task/queue/queue.go
Comment on lines +92 to +96
// Check maturity (can merge now?)
qi.CanMerge, qi.BlockedReason = CheckMaturity(&qi, opts.MinStage)

// Get conflict info from index if available
rec, ok, err := idx.Get(ctx, item.Name)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Re-evaluate maturity after loading conflict files

The merge-queue readiness check runs before conflict data is populated. CheckMaturity uses item.ConflictFiles to block tasks with base-branch conflicts, but ConflictFiles is filled from the index after that call, so tasks that already have recorded conflicts get marked CanMerge and included in the queue. This means queue list can show them as ready and queue merge will try to merge them (only to fail in MergeTask). Move the conflict-file load before CheckMaturity or re-run the maturity check after loading conflicts to ensure known conflicts actually block the task.

Useful? React with 👍 / 👎.

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.

Queue for merging tasks

1 participant