Repository navigation
fix(platform): recheck task access before notification delivery - #4056
Conversation
A task's subscription outlives its subscriber's team membership, so a member taken off a project's only team kept receiving the task's new title and status through their bell and email, although the task itself refused them (#3631). Every task-bound notification row now passes one check where it is written: its recipient must be able to open the task's current project now. The rule is the one assertTaskReadable applies: a non-disabled member of the organization who is an owner or admin, or the project is organization-wide, or the member belongs to one of its teams of this organization. Status changes, comments, mentions, assignments and unassignments, reviews, dates and agent notices all pass it. A row for anyone else is withheld: nothing is written, rewritten or cancelled. The debounced email rechecks the same rule when it sends, since access can end inside the debounce window. Subscriptions are kept, so a member who regains access hears about the tasks they follow again. Rows written while the person had access stay as history. projectReadersAmong (the failed-run notice's filter) and the new taskReadersAmong share one SQL statement. It also counts only teams of the organization, as getUserTeamIds does. The integration lane checkTaskNotificationAccess drives the real team-removal door, the task writers and the bell read. On d6dd53a the removed member received three rows carrying the renamed title, and a member of another organization only received rows here. Controls: a team watcher and an admin outside the team are told, a muted watcher is not, and history and rejoining work.
checkNotificationEmailSink and checkBellHintWire wrote task-bound rows for task ids no table holds, and the email lane's preference case wrote for a user outside the organization. A task-bound row is now written only for someone who can open its task, so both lanes file their rows under real tasks of an organization-wide project, make the preference user a member, and remove what they add, since later lanes count the organization's members and projects.
…task Review follow-up on #3631. A date alert picked one person (the assignee, else the task creator, else the project creator) before the access check, so an assignee who had lost the project used up the alert on a withheld row. The sweep now offers the alert only to people who can open the task, and the overdue rung tells the first creator who still can. The agent-question count leaves withheld rows out. The email lane asserts that its preference case writes its row. Two comments no longer overclaim, the reader rule says it reads the stored member role, and the French docs sentence names the project's tasks.
|
Independent review: accepted at tree
Verdict: the fix is right.
Local checks, on a private Postgres 16 + pgvector with synthetic data and no egress
CI
Non-blocking (P3), for follow-up
Your three questions
Not covered: no production contact. I didn't drive a real browser, because the change has no UI surface: the bell rows are verified at the API and database level in the lane. |
|
Status from TALE-359 (agent #2, run
|
|
Exact-head check before merge (TALE-359, agent #2, run
|
…#4165) Follow-ups from the #4056 review, with no change to who receives notifications. The EN and DE notification docs now use the UI's Watch wording; FR already matched. New tests pin the existing behaviour: a former reader's unread assignment row stays unchanged when the task is reassigned, the overdue reminder falls back from the task creator to the project creator only while that person can still open the task, disabled members and members of another organization's team receive nothing in the real-Postgres lane, and the bell-hint lane deletes its project when a step or a tail close fails. A docs test checks the Watch wording in all three languages. Closes #4077
What changed
A task subscription outlives its subscriber's team membership. So a member taken off a team-restricted project kept getting the task's new title and status in their notifications and email, although the task itself answered them
403 TASK_FORBIDDEN(#3631).writeCoalescedNotification(collab/service.ts) writes a row with ataskIdonly when its recipient can open the task's current project now. Otherwise it writes, rewrites and cancels nothing and returnswithheld. This covers every emitter, whoever picked the recipient: watchers (status, comments), mentions, assignment and unassignment, reviews, date sweeps and agent notices.assertTaskReadableapplies: a non-disabled member of the task's organization who is an owner or admin, or the project is organization-wide, or the member belongs to one of its teams. Only teams of that organization count, asgetUserTeamIdscounts them.projectReadersAmong(until now only the failed-run notice used it) and the newtaskReadersAmongshare one SQL statement, which adds the organization check on teams.email-sink.tschecks the same rule before it reads the address, because access can end inside the 60 s debounce window.checkNotificationEmailSink,checkBellHintWire), and one wrote for a recipient outside the organization. They now use real tasks of an organization-wide project and clean up after themselves.admin/teams.mdin EN, DE and FR gains one paragraph: notifications follow project access.No migration, no new strings, no API change.
How it was verified
Source
d6dd53ae0b9bd154f85d2f325ffadc3b56b46883, headb2a807d9d3ffbcded7c9312ee497890e3bdfd118(commitsde552b54cfix,ff9240dablane fixtures,b2a807d9dreview follow-up). Local Postgres 16.14 + pgvector, no egress, synthetic data.Reproduction before the fix. The new lane
checkTaskNotificationAccessdrives the real team-removal door (DELETE /api/app/teams/members/by-id/…), the realupdateTask,updateTaskStatus,addTaskCommentandassignTask, and the bell's ownlistMyNotifications/myUnreadCount. Ond6dd53ae0(round r02main):task_unassigned,task_commentedandtask_status_changedcarrying the renamed title, with unread = 3;Controls:
Before/after, same 13 notification lanes (
checkBellHintWire,checkNotifications,checkNotificationEmailSink,checkNotificationProjectBackfill,checkCollabMentions,checkTaskDescriptionMentions,checkReviewArc,checkErasureReviewHandoverRaces,checkTriggerPauseAfterFailures,checkAskAnswer,checkAnsweredAskRecovery,checkAgentRunFailureNotice,checkTaskNotificationAccess), run on the head and with main's two collab files swapped in:pg_search), and the two email-sink checks withemails=0. On the head their writes match main (inserted/rewritten/cancelled). Capture works in CI, where both pass on main.Unit tests (
collab): 4 files, 56 tests pass. Against main's sources, the new cases fail:Guards and scanners:
tests/guards/*, error-code registry, handler names, OpenAPI spec, rate limit and invalid-body: 20 files, 306 tests pass. Docs suite: 37 files, 222 tests pass.Static checks: scoped
tsc --noEmitover the changed files,integration-check.tsincluded: exit 0.oxlint --type-awareon the changed backend files: clean.oxfmt --check: clean.commitlint: clean.Review follow-up (
b2a807d9d)An independent read-only pass over
de552b54c..ff9240dabfound no high-severity issue. Its one medium is fixed here:d6dd53ae0'sdate-notifications.ts.Lows, also fixed:
pref=inserted).memberrole. A trusted-headers session's role is written back to it at each sign-in; between sign-ins, a role change in Settings can differ from the session for up to a session lifetime.Left for follow-up:
Local round
r09headonb2a807d9d, 13 notification lanes: 74/77. The 3 failures are environmental: BM25 and the box's email capture (emails=0, writes as on main).Review notes
integration-check.ts.git merge-treewith fix: name budget-rule keys, explain empty chat replies, land docs labels #4012 is clean. fix(platform): preserve approval decisions and scope card recovery #3881's conflicts are in files this PR doesn't touch.Closes #3631