Skip to content

fix(tasks): block child issues from running while parent is incomplete (#970) - #1650

Closed
jmoney8896 wants to merge 1 commit into
multica-ai:mainfrom
jmoney8896:fix/970-parent-child-task-blocking
Closed

fix(tasks): block child issues from running while parent is incomplete (#970)#1650
jmoney8896 wants to merge 1 commit into
multica-ai:mainfrom
jmoney8896:fix/970-parent-child-task-blocking

Conversation

@jmoney8896

Copy link
Copy Markdown
Contributor

What does this PR do?

Makes the task scheduler respect the parent_issue_id relationship. Previously child issues were
picked up in parallel with their still-running parents, which defeated the sub-issue hierarchy
users rely on to model ordered work.

Applies the reporter's preferred SQL-level fix (Option A in #970) to both scheduling paths:

  • ListPendingTasksByRuntime — LEFT JOINs issue twice (task's own issue + its parent) and
    excludes tasks whose parent is not done/cancelled.
  • ClaimAgentTask — same filter inside the atomic claim subquery so the claim can't sneak a
    blocked child through.

Both queries treat chat tasks (issue_id IS NULL) and top-level issues (parent_issue_id IS NULL) as always-eligible so nothing else changes.

Related Issue

Refs #970

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Changes Made

  • server/pkg/db/queries/agent.sql — add parent-status filter to ListPendingTasksByRuntime and
    ClaimAgentTask.
  • server/pkg/db/generated/agent.sql.go — regenerated-style output matching the SQL change. Run
    sqlc generate to verify my hand-edit matches.

How to Test

  1. cd server && go build ./... — clean.
  2. go test ./internal/service/... ./internal/handler/... — existing tests (mock-based) still
    pass. The SQL change is straightforward and will be exercised by the integration suite on CI.
  3. Integration: create a parent issue + child issue both assigned to agents; set parent to
    in_progress; observe that only the parent task starts. Transition parent to done; child task
    starts on the next claim cycle.

Checklist

  • Tests run locally and pass
  • No breaking changes to data model or API shape
  • Dedicated integration test for parent-gate — happy to add in a follow-up if reviewers prefer
    (would need the fixture harness used by repocache tests, not the mock Queries used by service
    tests)

AI Disclosure

AI tool used: Claude Code

Prompt / approach: Followed the reporter's clear root-cause diagnosis in #970, applied their
preferred SQL-level fix across both scheduler entry points (not just ListPendingTasksByRuntime).
Each edit reviewed before apply.

multica-ai#970)

agent_task_queue scheduling ignored parent_issue_id entirely — children
were picked up in parallel with their parents, defeating the sub-issue
hierarchy users rely on to model ordered work. Reproducible with e.g.
[Infra] Phase 1 parent + [Feature] Phase 2 child in the same backlog.

Reporter's preferred fix (Option A in multica-ai#970): filter at the SQL level on
both scheduling paths.

- `ListPendingTasksByRuntime` now LEFT JOINs `issue` twice (task's own
  issue + its parent) and excludes tasks whose parent is NOT in
  {'done','cancelled'}.
- `ClaimAgentTask` gets the same filter in its subquery so the atomic
  claim can't sneak a blocked child through.

Both queries treat chat tasks (`issue_id IS NULL`) and top-level issues
(`parent_issue_id IS NULL`) as always-eligible so nothing else changes.

Existing service tests (mock-based) still pass; the SQL change is
straightforward and will be exercised by the integration test suite on
CI. Happy to add a dedicated parent-gate test in a follow-up if
reviewers prefer.

Refs multica-ai#970
@vercel

vercel Bot commented Apr 24, 2026

Copy link
Copy Markdown

@jmoney8896 is attempting to deploy a commit to the IndexLabs Team on Vercel.

A member of the Team first needs to authorize it.

@Bohan-J

Bohan-J commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Closing — this problem is covered by newer work.

Three open PRs have been targeting parent/child issue blocking:

Since #5616 enforces the invariant at the write boundary rather than only in the claim query, it subsumes the data-layer approach here. Closing this branch so the work converges.

Thanks for raising it — the underlying issue (#970) was a real gap.

@Bohan-J Bohan-J closed this Jul 31, 2026
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.

2 participants