Repository navigation
Closed
Description
Context
The request says the task detail page must "show the task assignment status" and that "from there it should be possible to change the assignment (assign one or multiple users to it)". The list API from the previous task projects assignees for reading, but a detail page also needs to write them, and it needs a list of candidate assignees to choose from.
That is three things the list endpoint cannot provide:
- A fresh read. The list serves the cached projection on purpose, so it never calls GitHub. The detail page is a single task opened deliberately, so it can afford one GitHub read and should show the true current state, including an assignment a teammate just made in the GitHub UI.
- A write path, which must go through
setTaskAssigneesso GitHub stays the authority. - Candidates: the repository's assignable users, so the UI offers a picker rather than a free-text login box.
This task adds packages/api/routes/taskAssignmentRoutes.ts with those three handlers and registers them. Authorisation follows the existing task routes: any authenticated member may read, and writing requires GitHub write access to the repository, which is the same bar GitHub itself enforces on assignment.
Requirements
- Add
createTaskAssignmentRoutes({ db })exposing:getAssignees-GET /api/task/:taskId/assignees, returning the current assignees and the task's GitHub subject, refreshed from GitHub unless?refresh=false.putAssignees-PUT /api/task/:taskId/assignees, body{ logins: string[], mode?: 'add' | 'replace' }, defaulting toreplacebecause this endpoint represents an explicit operator decision.getAssignableUsers-GET /api/task/:taskId/assignable-users, the repository's assignable users, paginated and bounded.
- Validate
taskIdwithvalidateTaskId, and the body with the shared login validator; answer 400 on malformed input. - Return 404 when the task does not exist, and 409 with an explanatory message when the task has no GitHub issue or pull request to assign (for example a goal task).
- Require repository write access for
putAssignees, reusingverifyGitHubRepositoryAccess/handleGitHubRepositoryAccessErrorfrompackages/api/githubMetadataAuth.ts. - Map
TaskAssignmentErrorcodes onto HTTP:NO_SUBJECTto 409,UNKNOWN_LOGINto 400,GITHUB_REJECTEDto 422. - Cache the assignable-users read briefly in memory, because the picker is opened repeatedly and the list changes rarely.
- Register the three routes in
packages/api/routeRegistry.tsunder the operational entries, and export the factory frompackages/api/routes/index.ts. - Tests in
packages/api/test/covering each handler, the authorisation rules and the error mapping.
Implementation Specification
Files added
packages/api/routes/taskAssignmentRoutes.tspackages/api/test/taskAssignmentRoutes.test.ts
Files modified
packages/api/routes/index.ts- export the factory from the barrel.packages/api/routeRegistry.ts- add the dependency and the three route entries.packages/api/server.ts- construct the routes and pass them to the registry.
Step-by-step
- Write the route module. Read the task row once, resolve its subject with
resolveTaskSubject, and branch on the result before doing any GitHub work. getAssigneescallssyncTaskAssigneesby default andloadTaskAssigneeswhenrefresh=false, so a UI poll can choose the cheap path.putAssigneeschecks write access, then callssetTaskAssigneeswith the requested mode, and returns the confirmed set.getAssignableUserscallsGET /repos/{owner}/{repo}/assignees, caches for 60 seconds per repository, records the observed profiles, and caps the result.- Register the routes in
routeRegistry.tsbeside the other/api/task/:taskId/...entries, and wire the factory inserver.ts. - Add the test file.
Acceptance Criteria
npm run typecheck,npm run lintand the API tests pass.npm run gen:openapi:checkandnpm run check:client-contractpass, or the generated artifacts are regenerated in this change.GET /api/task/:taskId/assigneesreturns{ assignees, subject }; withrefresh=falseit makes no GitHub call.GETon an unknown task returns 404; on a goal task with no issue or PR it returns 409 with a message explaining that the task has nothing to assign.PUTwith{ logins: ['octocat'] }assigns on GitHub and returns the confirmed set.PUTwith{ logins: [] }and the default mode clears the assignment.PUTwithmode: 'add'leaves pre-existing assignees in place.PUTfrom a user without repository write access returns 403 and changes nothing on GitHub.PUTwith an unknown login returns 400; one GitHub rejects returns 422; a task with no subject returns 409.PUTwith a malformed body (not an array, a non-login entry, more than ten entries) returns 400.GET /api/task/:taskId/assignable-usersreturns a bounded list and serves a second call within the cache window without a GitHub request.- No change in behaviour for any existing route.
Created by ProPR AI Planner
Activity
propr-dev commentedon Oct 8, 2026
Suggested Implementation:
Implementation Approach
The detail page has a different cost profile from the list, and that difference drives the design. The list serves the cached projection because it renders many tasks at once; the detail page serves one task the operator deliberately opened, so it can afford a single GitHub read and should therefore show the truth rather than the cache. Making the detail endpoint refresh by default (with
refresh=falsefor polling) is what makes "a teammate assigned this in the GitHub UI" visible without a background sync job.Three alternatives were weighed for the write path:
taskRoutes.tsis already near the file's complexity ceiling and mixes list, revert, delete and follow-up concerns. A separate module keeps the assignment authorisation rule in one readable place.Authorisation is deliberately asymmetric. Reading assignment is no more sensitive than reading the task, so any authenticated member may do it. Writing changes state in the customer's GitHub repository, so it requires GitHub write access - checked against GitHub rather than against ProPR roles, because GitHub is the system whose state is being changed and it is the authority on who may change it.
modedefaults toreplacehere, the opposite of the service default. That is intentional: the service default protects automated paths from clobbering a human, while this endpoint is the human, and a picker that cannot unassign anyone would be broken.The assignable-users cache is small and in-process. A Redis cache would be more correct across replicas but is not worth the coupling: the list changes on the timescale of repository membership changes, and a 60-second in-process window already removes the repeated calls from opening the picker several times.
File:
packages/api/routes/taskAssignmentRoutes.ts(new file)Why this file: a separate module keeps the one rule that matters - reads are open, writes need GitHub write access - visible in a single file, rather than buried in the middle of
taskRoutes.tsalongside revert and delete. It is also the only place that translatesTaskAssignmentErrorcodes into HTTP statuses, so every caller gets the same mapping.File:
packages/api/routes/index.tsWhy this file:
server.tsconstructs every route module through this barrel, so the factory is unreachable until it is re-exported here.File:
packages/api/routeRegistry.tsWhy this file: the registry is the single declarative route table, and
assertNoDuplicateRoutesplus the OpenAPI generator both enumerate it. A route added anywhere else would be invisible to the generated client contract.@@ in the destructuring inside createOperationalRouteEntries taskHistoryRoutes, + taskAssignmentRoutes, taskRoutes, @@ beside the other /api/task/:taskId entries ['get', '/api/task/:taskId/history', taskHistoryRoutes.getTaskHistory], + // Grouped with the other per-task reads so the task surface stays in one + // place in the table. + ['get', '/api/task/:taskId/assignees', taskAssignmentRoutes.getAssignees], + ['put', '/api/task/:taskId/assignees', taskAssignmentRoutes.putAssignees], + ['get', '/api/task/:taskId/assignable-users', taskAssignmentRoutes.getAssignableUsers], ['get', '/api/task/:taskId/live-details', liveDetailsRoutes.getLiveDetails],File:
packages/api/server.tsWhy this file:
setupRoutesconstructs each module and hands the results to the registry, so the new module has to be built here or the registry has nothing to register.File:
packages/api/test/taskAssignmentRoutes.test.ts(new file)Why this file: the authorisation rule and the error mapping are the whole point of this module, and neither is visible from a successful assignment. These tests pin "a read is open, a write needs GitHub write access" and the three error statuses so a later refactor cannot quietly widen the write path.
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-52891/claude-opus-5-5-add-task-assignment-read--20261009-0221-1p62888-epic-task-assignment-1m4issue-2891-20261009-0221-claude-opus-5-5-1p6🔍 Track Task Execution