Skip to content

fix(platform): retarget reviews after access loss - #4387

Closed
yannickmonney wants to merge 1 commit into
mainfrom
fix/task-review-access
Closed

yannickmonney wants to merge 1 commit into
mainfrom
fix/task-review-access

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

Waiting task reviews are now revalidated when a member is removed, demoted, disabled, or removed from a project audience team. Pending requests are handed to the existing fallback reviewer, notifications and task hints are refreshed, and the designation remains auditable.

Verified: oxfmt, oxlint, git diff --check. Targeted Vitest could not load because the repository test setup exposes zod/v4 as undefined.

Closes #3789

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Independent exact-head verdict (Codex #9, TALE-905): REQUEST CHANGES on 0e510afdeb687d0de5bfb95d5fff9df666f8b8af. I am not implementer Codex #5. This comment also carries the requested verdict for TALE-244 and TALE-359 (3729d02a-eb44-42b2-a68e-1bec2cebbcd6): the task connector's initial workspace_status call returned unavailable / not_granted, so direct task comments are unavailable and I am using the specified PR fallback.

Blocking findings:

  1. P2 — Pending recipients are missed, and removed designations are retained. reviews.ts:565 discovers only in_review tasks with reviewer_user_id = affectedUser. A review minted for the task/project creator can have no explicit designation; after an earlier fallback, its live recipient can also differ from the stored designation. Removing/demoting that live recipient therefore leaves the approval's requestedFor/typed recipient untouched. Additionally, neither this helper nor removeMember clears the removed user's designation, including tasks not yet in review (the issue's R2). Discover pending human recipients from approval metadata as well as designations, and clear removed designations in the same transaction, as the existing erasure pass does.
  2. P2 — Some role changes that lose edit access never revalidate. members/service.ts:450 calls the helper only for member/disabled. An admin designated on a team-restricted project can be demoted to editor/developer while belonging to none of its audience teams. They lose project access, but keep the pending review. Revalidate actual post-change eligibility rather than limiting this to two destination roles.
  3. P2 — Team removal reroutes reviewers who still can edit. reviews.ts:570 unconditionally excludes the affected user. An editor still in another audience team, or an admin/owner, remains eligible after leaving one team, yet their review moves to the creator (or becomes unassigned). A review-only behavioral reproduction confirms the admin case. Check eligibility first and leave an eligible recipient alone.
  4. P2 — Archived tasks generate actionable requests. The new scan does not load archive state or pass silent. Archiving preserves an open review, so removing its reviewer now asks the fallback about a hidden, unworkable card. The existing erasure path explicitly passes silent: task.archivedAt !== null. A review-only reproduction confirms notification fan-out for an archived task.
  5. P2 — Team-path races are not protected by the review's transaction contract. teams/routes.ts:358 uses plain sql.begin; its lock is on the team, not the task/review. The new scan reads an unlocked task snapshot, then invokes a helper that updates by approval id/status without checking the captured recipient or the update result. Concurrent reviewer changes can be overwritten; a concurrent decision can make the update affect zero rows while the helper still dismisses/bells. A recording-transaction reproduction confirms the latter fan-out. This needs task/review synchronization or retryable serialization plus guarded writes and fan-out only for a successful change.

Coverage boundary: this is backend code in the appropriate domain, but SCIM removal/role/team updates, Better Auth's afterRemoveMember cascade, and OIDC role reconciliation still bypass the new helper. They cannot satisfy an organization-wide access-loss guarantee. No new regression tests or automation-register row ship in this three-file diff.

Verification at this head, existing dependencies only:

  • /opt/node/bin/node …/vitest.mjs run --project server --maxWorkers 1: review retarget/routing/member, member service and team routes: 75 passed, 1 failed. The team removal test receives 500 because its transaction fake has no tx.unsafe, reached by the new helper. The same team suite at parent 9e8628ab2692b55c9f3e3774d2d446f58a317f83 passes 16/16, attributing this failure to the PR. Zod setup did not fail under Node; no font workaround was needed.
  • Eight additional importer/cascade/SCIM suites: 89/89 passed, one worker.
  • Three review-only tests reproduce the bad eligible-admin, archived-request and zero-row-update effects (3/3 reproductions passed; these are evidence of defects, not product regression passes).
  • Scoped oxlint --type-aware: fails at reviews.ts:571, typescript/no-unsafe-type-assertion on the partial-row-to-TaskRow cast. Scoped oxfmt --check and git diff --check: pass.
  • Scoped TypeScript program rooted at the three changed files, with the repository's existing PDF worker declaration and a 2304 MiB heap cap: pass; no whole-workspace check.
  • EN/DE/FR contain the reused review-request keys. No new UI strings or register lines are added, so no new translation omission/register-line collision was found. Existing retargeting preserves run/round metadata and skips decided/workflow-era rows; no separate automatic per-review routing audit record is added. I did not run a browser session.

CI: at the final refresh the head remained exact. The current PR base is ac7f3f55e979d0386ddc40e465bc64f442b9ae81 (the reported compact-age fix). Checks are still largely queued, not settled: 20 queued, 3 success, 11 skipped in the observed rollup. The watcher also encountered a GitHub connection failure. There are no observed failing CI logs to attribute, and these results are not an all-green gate. The local team-test and lint failures above are independently attributable to this diff.

PostgreSQL proof still required: actual approval-recipient discovery/array SQL, concurrent removal vs mint/decision/CAS handoff, concurrent access changes affecting fallback eligibility, duplicate/replayed mutations and notification idempotency, archive visibility, tenant isolation and retained audit records across the app/auth/SCIM doors. No local PostgreSQL was available; the recording mocks do not prove those database properties.

No push, merge, CI rerun, or task/status change performed. Review artifacts and logs are in the TALE-905 delivery box.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Exact-head review of replacement #4396 (9e440ab): REQUEST CHANGES. #4396 contains #4387 plus repairs and should survive once corrected; close #4387 afterward. See full verdict: #4396 (comment)

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Superseded by #4396

@yannickmonney
yannickmonney deleted the fix/task-review-access branch October 13, 2026 10:07
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.

bug(platform): a waiting task review stays with a reviewer who was removed or lost edit access

1 participant