Repository navigation
Closed
Description
Context
The previous task added followup_requires_assignment as configuration, defaulted off, with nothing reading it. This task makes it take effect.
Comment intake has two paths that must agree, or the gate becomes a race:
processCommentEventinpackages/core/src/webhook/commentEventHandler.ts, for webhook and ProPR Connect deliveries.pollForPullRequestCommentsinsrc/polling/prCommentPolling.ts, the fallback used in polling intake mode.
Both already run an author filter (filterCommentByAuthor) and a trigger check (checkCommentTrigger / processing label). The gate is a third, per-task check: is this comment's author assigned to the task this pull request belongs to?
Three semantics need deciding, and the UI copy from the previous task already commits to them:
- A pull request with no assignees is unaffected. Otherwise every single-developer instance breaks the moment the setting is enabled.
- ProPR's own system comments are never gated. The CI-failure follow-up marker and the system
/ultrafixcomment are authenticated by their marker, not by a person, and gating them would silently disable auto CI follow-up and Ultrafix. - The gate fails closed. If the assignment projection cannot be read while the gate is on, the comment is not processed. A gate that opens under failure is not a gate.
Requirements
- Add
packages/core/src/webhook/followupAssignmentGate.tsexportingcommentAuthorMayFollowUp({ repoOwner, repoName, pullRequestNumber, authorId, authorLogin, systemAuthored }), returning a decision plus a reason. - Resolve the decision from the live pull request assignees, not the stored projection, so an assignment made seconds earlier is honoured; refresh the projection as a side effect.
- Return "allowed" when the pull request has no assignees, and "allowed" when
systemAuthoredis true. - Return "denied" when the gate is on, the pull request has assignees, and the author is not among them; return "denied" when the live read fails.
- Wire into
processCommentEventafter the author and ignore-keyword filters and before the slash-command branch, so a gated/reviewor/fixis refused too; answer with aDeliveryDispositionof{ status: 'ignored', reason: 'author_not_assigned' }so the delivery is acknowledged and no seat is billed. - Wire into
collectUnprocessedCommentsinprCommentPolling.ts, evaluated once per pull request rather than once per comment. - Post a one-time explanatory comment when a gated comment is refused, deduplicated in Redis per (pull request, author), so a person is told why rather than being ignored silently.
- Log every refusal at
infowith repository, pull request, author and reason. - Tests covering: gate off, no assignees, assigned author, unassigned author, system-authored comments, slash commands, a failed read, and the one-time notice deduplication.
Implementation Specification
Files added
packages/core/src/webhook/followupAssignmentGate.tstest/followupAssignmentGate.test.ts
Files modified
packages/core/src/webhook/commentEventHandler.ts- evaluate the gate.packages/core/src/index.ts- export the gate.src/polling/prCommentPolling.ts- evaluate the gate per pull request.
Step-by-step
- Write the gate module. Short-circuit on
loadFollowupRequiresAssignment()being false before any GitHub call, so the disabled path costs nothing. - For system-authored comments, reuse the existing signals already computed in
processCommentEvent:isCiFailureFollowupCommentand the bot-authored/ultrafixcase. - In
processCommentEvent, place the check after the ignore-keyword filter and beforeparseSlashCommand's dispatch, and pass the computedisSystemCiFollowupComment/isSystemUltrafixCommentflags assystemAuthored. - In
prCommentPolling.ts, evaluate once per pull request incollectUnprocessedCommentsand skip the whole pull request when the author set is gated; evaluate per author since a pull request can have comments from several people. - Post the notice through the existing authenticated Octokit, keyed in Redis with a TTL so a long-running conversation produces one explanation rather than one per comment.
- Add tests.
Acceptance Criteria
npm run typecheck,npm run lintand the server tests pass.- With the setting off, intake behaviour is byte-identical: no GitHub call is added and no code path changes.
- With the setting on and the pull request unassigned, every comment is processed exactly as before.
- With the setting on and the pull request assigned to A: a comment from A starts work; a comment from B is ignored with reason
author_not_assigned, and nothing is queued. - A gated
/review,/fixor/ultrafixfrom an unassigned author is refused, and the comment is not claimed in Redis, so a later legitimate delivery is not treated as a duplicate. - The CI-failure follow-up comment and the system
/ultrafixcomment are processed regardless of assignment. - A refused author receives exactly one explanatory comment per pull request within the deduplication window.
- When the live assignee read fails while the gate is on, the comment is not processed and the refusal is logged.
- The polling path reaches the same decision as the webhook path for the same inputs, and evaluates the gate once per pull request.
- Refusals are acknowledged deliveries, not failures: no retry storm and no billed seat.
Created by ProPR AI Planner
Activity
propr-dev commentedon Oct 8, 2026
Suggested Implementation:
Implementation Approach
The gate is a third filter in a pipeline that already has two, so the main design question is where it sits and what it reads.
Where it sits. It must run before
parseSlashCommanddispatch. Slash commands are the most powerful follow-up inputs -/fixwrites commits,/mergemerges,/ultrafixstarts a loop - so a gate placed after them would protect ordinary comments and leave the dangerous ones open. It must run after the author and ignore-keyword filters, because those are cheaper and because the system-comment detection they produce is exactly what the gate needs to avoid gating ProPR's own comments.What it reads. Two options:
task_assigneesprojection. Rejected: the projection is refreshed on assignment events and after ProPR's own writes, so there is a window where someone assigns a teammate in the GitHub UI, that person comments, and the gate refuses them. For a gate, that window is a support ticket.GET /issues/{n}per gated delivery, only when the setting is on, and it refreshes the projection as a side effect so the Tasks list benefits from the same call.Failure direction. This is the one place in the feature where failing closed is right. With the gate on, an unreadable assignment state means ProPR cannot tell whether this person is allowed to start work; starting it anyway would defeat the setting. That is the opposite of the
loadFollowupRequiresAssignmentaccessor, which fails open - a corrupt setting value must not stop every follow-up on the instance. Narrow check closed, broad switch open.The explanatory comment. Silently ignoring a teammate's comment is the worst possible behaviour: there is no feedback anywhere, and the natural conclusion is that ProPR is broken. One comment per (pull request, author), deduplicated in Redis with a TTL, tells them what happened without turning a long thread into a wall of identical notices.
System comments.
isCiFailureFollowupCommentand the bot-authored/ultrafixcase are already computed inprocessCommentEvent, and both are authenticated by a marker rather than by a person. Passing those flags into the gate rather than re-deriving them keeps one definition of "ProPR said this", and avoids the gate silently disabling auto CI follow-up and Ultrafix continuation.File:
packages/core/src/webhook/followupAssignmentGate.ts(new file)Why this file: one decision function shared by the webhook and polling paths. Two separate implementations would drift, and a gate that answers differently depending on intake mode is worse than no gate - it would let a comment through on a polling instance that a webhook instance refused.
File:
packages/core/src/webhook/commentEventHandler.tsWhy this file: this is the single intake funnel for webhook and Connect deliveries, and it is where the author filter, the ignore-keyword filter and the system-comment detection already live. Placing the gate here - before the slash-command dispatch - is what makes it cover
/fix,/mergeand/ultrafixas well as ordinary comments.@@ in processCommentEvent, after the ignore-keyword check and before the slash-command branch const ignoreResult = checkCommentIgnore(comment.body, ignoreKeywords, correlationId); if (shouldIgnoreSystemComment(ignoreResult.shouldIgnore, isSystemCiFollowupComment)) { return { status: 'ignored', reason: 'ignore_keyword' }; } + // Evaluated before the slash-command dispatch on purpose: /fix writes + // commits, /merge merges and /ultrafix starts a loop, so a gate placed + // after them would protect ordinary comments and leave the powerful ones + // open. The system flags computed above are passed through so ProPR's own + // marker-authenticated comments are never gated. + const gate = await commentAuthorMayFollowUp({ + repoOwner: owner, + repoName: repo, + pullRequestNumber: prNumber, + ...(payload.sender?.id === undefined ? {} : { authorId: String(payload.sender.id) }), + authorLogin: commentAuthor, + systemAuthored: isSystemUltrafixComment || isSystemCiFollowupComment, + }); + if (!gate.allowed) { + correlatedLogger.info({ + repository: repoFullName, pullRequestNumber: prNumber, commentId: comment.id, + commentAuthor, reason: gate.reason, assignees: gate.assignees, + }, 'Follow-up refused: comment author is not assigned to this task'); + // Explained once, so a refused teammate is told why instead of + // concluding that ProPR is broken. + await explainFollowupRefusal(redisClient, { + repoOwner: owner, repoName: repo, pullRequestNumber: prNumber, authorLogin: commentAuthor, + }, gate); + // An acknowledged delivery, not a failure: the webhook must not be + // retried, and no billing seat is consumed. The comment is also NOT + // claimed in Redis, so a later legitimate delivery of the same comment + // (after the author is assigned) is not mistaken for a duplicate. + return { status: 'ignored', reason: 'author_not_assigned' }; + } + // Parse slash commands (/review, /fix, /merge, /switch, /use) before generic follow-up logic if (parsedCommand) {File:
packages/core/src/index.tsWhy this file: the polling path lives in
src/polling/and imports from@propr/core, so the gate has to be on the barrel for both intake paths to share one implementation.File:
src/polling/prCommentPolling.tsWhy this file: polling intake is a complete second path to the same queue. If the gate were only in the webhook handler, an instance running
GITHUB_EVENT_INTAKE_MODE=pollingwould ignore the setting entirely - the kind of divergence that makes a security-adjacent setting untrustworthy.@@ in collectUnprocessedComments, inside the per-comment loop after the author filter const commentAuthor = comment.user.login; const filterResult = filterCommentByAuthor(commentAuthor, correlationId); if (filterResult.shouldFilter) continue; + // Evaluated per author rather than per pull request, because one pull + // request can carry comments from several people and each needs its own + // answer. Cached in gateDecisions so a thread with twenty comments from + // two people costs two reads, not twenty. + let gate = gateDecisions.get(commentAuthor.toLowerCase()); + if (!gate) { + gate = await commentAuthorMayFollowUp({ + repoOwner: owner, repoName: repo, pullRequestNumber: pr.number, + ...(Number.isSafeInteger(comment.user.id) ? { authorId: String(comment.user.id) } : {}), + authorLogin: commentAuthor, + }); + gateDecisions.set(commentAuthor.toLowerCase(), gate); + } + if (!gate.allowed) { + correlatedLogger.info({ + pullRequestNumber: pr.number, commentId: comment.id, commentAuthor, reason: gate.reason, + }, 'Follow-up refused: comment author is not assigned to this task'); + await explainFollowupRefusal(redisClient, { + repoOwner: owner, repoName: repo, pullRequestNumber: pr.number, authorLogin: commentAuthor, + }, gate); + // Not marked as processed in Redis: once the author is assigned, + // the next poll should pick the comment up rather than skip it. + continue; + } + // Check trigger: PR must have a processing label OR comment must contain trigger keyword@@ at the top of collectUnprocessedComments const unprocessedComments: UnprocessedComment[] = []; const recipientIds = new Set<string>(); let everyRecipientKnown = true; + // One decision per author for this pull request: the gate's GitHub read is + // the same for every comment by the same person. + const gateDecisions = new Map<string, Awaited<ReturnType<typeof commentAuthorMayFollowUp>>>();File:
test/followupAssignmentGate.test.ts(new file)Why this file: every branch of this gate has a distinct production consequence - a broken single-developer instance, a silently disabled Ultrafix loop, an open door for
/fix, or a retry storm - and none is visible from the happy path. The two intake paths are asserted against the same inputs because divergence between them is the failure that would make the setting untrustworthy.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-52896/claude-opus-5-5-enforce-the-assignment-ga-20261009-0936-j772888-epic-task-assignment-1m4issue-2896-20261009-0936-claude-opus-5-5-j77🔍 Track Task Execution