Repository navigation
Description
Context
The user request states that task assignment must be "mapped to Github PR/issue assignment directly". That makes GitHub the source of truth: assigning a task in ProPR must assign the underlying issue or pull request on GitHub, and an assignment made in the GitHub UI must show up in ProPR. ProPR therefore needs a local projection of that GitHub state so the Tasks list can render and filter assignees without one GitHub call per row.
This task adds that projection and the service that keeps it in step with GitHub. It deliberately contains no HTTP route and no UI: those land in the two tasks that follow, so this one stays reviewable on its own.
A task's GitHub subject is already resolvable from the existing tasks row: pr_number when the task produced or operates on a pull request, otherwise issue_number (see resolveFollowupThread in packages/api/routes/taskRoutes.ts, which makes the same choice for follow-up comments). GitHub treats pull requests as issues for assignment, so a single /issues/{n}/assignees endpoint covers both.
Requirements
- Create a
task_assigneesmigration:task_id,github_user_id,synced_at,created_at, a composite primary key on (task_id,github_user_id), and an index ongithub_user_idso the "assigned to me" filter is an indexed lookup. - Add
packages/core/src/services/taskAssignmentService.tsexposing:resolveTaskSubject(task)- returns{ owner, repo, number, kind }for the GitHub issue or PR a task is assigned through, or null when the task has neither.syncTaskAssignees(taskId)- reads the live assignees from GitHub and replaces the stored set in one transaction, caching the observed profiles.setTaskAssignees(taskId, logins, options)- writes to GitHub first, then persists what GitHub confirmed.loadTaskAssignees(taskIds)- batch read returningMap<taskId, AttributedUser[]>for list projections.taskIdsAssignedTo(githubUserId, options)- the id set behind the "my tasks" filter.isUserAssignedToTask(taskId, githubUserId)- used later by the follow-up gating setting.
setTaskAssigneesmust write GitHub first and persist only GitHub's response, so ProPR never shows an assignment GitHub rejected.setTaskAssigneesmust support additive and replacing semantics, and must never silently drop an assignee a human added in the GitHub UI unless the caller explicitly asked for a replacement.- Record every GitHub-observed assignee profile through
rememberGitHubUserProfiles, so the profile cache fills without extra API calls. - Reads fail soft (return partial data, log a warning); writes fail loud (throw, so the HTTP layer can report the failure).
- Re-export the service from
packages/core/src/index.ts. - Unit tests in
test/covering subject resolution, the replace-in-transaction behaviour, additive vs replacing writes, GitHub rejection handling and batch reads.
Implementation Specification
Files added
packages/core/src/db/migrations/20261012010000_create_task_assignees.jspackages/core/src/services/taskAssignmentService.tstest/taskAssignmentService.test.ts
Files modified
packages/core/src/index.ts- re-export the service.
Step-by-step
- Write the migration. Do not add a foreign key to
tasks: the delete path intaskRoutes.deleteTaskalready removes rows table by table inside a transaction, and a cascading constraint would change that behaviour. Add an explicit delete oftask_assigneestodeleteTaskin the API task of this plan. - Write the service.
resolveTaskSubjectreadsrepository,pr_number,issue_numberandtask_typefromtasks, reusing the "PR task" rule already encoded inpackages/api/routes/pullRequestTaskIdentity.ts. syncTaskAssigneesperformsGET /repos/{owner}/{repo}/issues/{issue_number}and replaces the stored set in a single transaction, so a concurrent read never sees a half-written set.setTaskAssigneesresolves logins to ids viaresolveGitHubUserProfileByLogin, callsPOST/DELETE /issues/{n}/assignees, then persists the assignees GitHub returned.- Re-export from core's barrel.
- Add tests with an in-memory SQLite database and a stub Octokit.
Acceptance Criteria
npm run typecheckandnpm run lintpass.- The migration creates
task_assigneeswith the composite primary key; rollback drops it. resolveTaskSubjectreturns the PR number for a PR-comment task, the issue number for an implementation task with no PR, the PR number once an implementation task has recorded one, and null when the task has neither.syncTaskAssigneesreplaces the stored set atomically: an assignee removed on GitHub disappears locally, one added appears, and a failed GitHub read leaves the previous set untouched.setTaskAssigneeswithmode: 'add'leaves pre-existing GitHub assignees in place; withmode: 'replace'it removes only those not in the requested set.- When GitHub rejects an assignee (for example a user without repository access, which GitHub silently ignores), the persisted set matches GitHub's response rather than the request.
setTaskAssigneesrejects with a typed error when a login cannot be resolved, and writes nothing locally.loadTaskAssigneesreturns an entry only for tasks that have assignees and performs one query regardless of the number of task ids.taskIdsAssignedTois scoped by repository when a repository is supplied.- Reads tolerate a GitHub outage; writes propagate the failure.
Created by ProPR AI Planner
Activity
propr-dev commentedon Oct 8, 2026
Suggested Implementation:
Implementation Approach
The request pins the design decision for us: assignment is "mapped to Github PR/issue assignment directly". So GitHub owns the state and ProPR keeps a projection. That rules out the two alternatives:
So: a
task_assigneesjoin table, refreshed from GitHub, with GitHub as the authority on every write.Three details are load-bearing.
Write-through ordering.
setTaskAssigneescalls GitHub before persisting, and persists GitHub's response rather than the request. GitHub silently drops assignees who lack repository access, so persisting the request would leave ProPR showing an assignment that does not exist. Writing GitHub first also means a failed write leaves no local trace to reconcile.Additive by default. The auto-assign feature in later tasks must "preserve existing manually assigned users". Making
addthe default andreplaceexplicit means the automated paths cannot remove a human's assignment by construction, rather than by every call site remembering to merge first.Transactional replace on sync.
syncTaskAssigneesdeletes and re-inserts inside one transaction. A non-transactional version has a window where the task looks unassigned, and that window is exactly when a "my tasks" filter or the follow-up gating check would read it and reach the wrong answer.No foreign key to
tasks:deleteTaskinpackages/api/routes/taskRoutes.tsalready deletes dependent rows explicitly inside a transaction, and adding a cascade would make this table behave differently fromtask_historyandllm_executionsbeside it.File:
packages/core/src/db/migrations/20261012010000_create_task_assignees.js(new file)Why this file: a join table rather than a JSON column on
tasks, because the "assigned to me" and "assigned to these users" filters must be an indexed SQL predicate. A JSON array would force aLIKEscan over every task row, and the Tasks list already pages over the full table.File:
packages/core/src/services/taskAssignmentService.ts(new file)Why this file: the one place that knows how a ProPR task maps onto a GitHub issue or pull request, and the only place that writes assignment. Keeping the GitHub-first ordering and the additive default here means the HTTP route, the worker auto-assign path and the MCP tool cannot each get the ordering subtly wrong.
File:
packages/core/src/index.tsWhy this file: the API routes, the worker auto-assign path and the comment intake gate all import from
@propr/core, so the service has to be on the barrel to be reachable.File:
test/taskAssignmentService.test.ts(new file)Why this file: the service's correctness is almost entirely in behaviour that a happy-path call cannot show - what happens when GitHub drops an assignee, when a replace must not churn a kept assignee, and when a sync fails midway. These tests pin the GitHub-first ordering so a later refactor cannot invert it.
propr-dev commentedon Oct 9, 2026
🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
claudeclaude-opus-5-52889/claude-opus-5-5-persist-task-assignees-an-20261009-0011-6kg2888-epic-task-assignment-1m4issue-2889-20261009-0011-claude-opus-5-5-6kg🔍 Track Task Execution