Repository navigation
fix(platform): close the reviewer edge cases after re-targeting - #3554
Conversation
About 190 app doors answered a body their schema refused with a bare
`{ error: 'invalid body' }`: the dialog could only say "invalid body",
and the error report carried the same opaque code, so nobody could tell
which field the form had let through.
Every door now answers through `backend/lib/invalid-body-response.ts`:
the same `invalid body` code, a `field: reason` message and the issues
under `data.issues`. `invalidBodyIssuesResponse` covers a refusal no
schema raised (a body that is not JSON, the automation save's missing
`document`). An email with neither body nor files is refused at
`content`. A guard test fails any bare literal left under `backend/`.
The caps a form has to mirror now live where the app can read them:
the contact caps beside the contact patterns in `lib/shared`, the
object-storage connection caps in its shared schema, and the Postgres
host rule and password cap in `@tale/shared/schemas/knowledge`.
The UI evaluations kept hitting `invalid body` on Products, Contacts and Data residency (TALE-84, TALE-162, TALE-103): each form let through a value the door refuses. - Contacts: the form trims and caps Name (300), Email (320, at most 64 characters before the `@`), Phone (50) and Locale (20) with the shared caps, and both dialogs put a refused body's reason on the toast. - Products: a pasted image address must be an absolute http(s) URL (or the app path an upload returned); the error sits under Image URL. - Data residency: Test connection checks the fields the way Save does and names what it would refuse instead of sending it; required fields are judged trimmed, as they are sent, and every field has the door's length cap. - The default mutation and action toasts (and the task toasts) show an `invalid body` refusal's field-naming sentence instead of "Try again". New `products.edit.validation.imageUrl` in en, de and fr; the product and self-hosted data-residency docs say what the forms check, in all three languages. Manual boxes KNOW-B13 and DATA-B8, with the owning specs in the automation register.
The workspace-tool bridge kept only the code of a domain refusal. An agent's task_create with a description over 20,000 code units or a label over 50 came back as "TASK_DESCRIPTION_INVALID: the domain refused these arguments.", so the model could not tell which limit it broke. The domain threw one "Invalid title" for an empty and an over-long title on the human create and edit paths, and the tasks app door dropped the domain's message altogether. - core/tasks/helpers.ts now holds the refusal sentences beside the limits. Each names the cap, the unit every cap is measured in (UTF-16 code units, where most emoji count as 2) and the length measured, never the value. validateTitle tells an empty title from an over-long one, and the description, label count, label name and comment caps are named. - toolResultFromError relays the domain's sentence beside the code, and nothing else from the refusal's payload. - The agent-comment writer moves into the coded write shim, so an over-long comment answers invalid_args instead of error. - workspace_status states every cap of task_create, task_comment and task_upsert_by_external_ref from the shared constants, in code units. - The tasks app door answers a domain refusal with its message, and an empty title on create reaches the domain instead of a bare invalid body. Closes #3155
Three gaps left open by the reviewer re-target (#3517): - Erasure stamped a review still waiting on the subject with the pseudonym, so it waited on nobody. The review pass now clears the designation first, hands each waiting review on through the chain a cleared designation takes (task creator, then project creator, the subject skipped in every slot) and rings the new reviewer as the system; only what still names the subject is pseudonymized after. - Changing or clearing the reviewer before In review left the previous designee's unread "You're the reviewer" heads-up ringing; it is now marked read when the designation moves. - A designee who cannot edit the project was stored and then routed past at mint. The designation is held to the same rule the gate resolves by (reviewerEligibility) and refused with 400 TASK_REVIEWER_NO_EDIT_ACCESS; the task dialog names the refusal with the picker's own hint. Manual boxes PROJ-F33, PROJ-F34 and PROJ-B9, their automation rows, the error-code row, and the data subject request docs (EN/DE/FR).
asAppError translated every error carrying a string code and a numeric status, so a MentionDirectoryError (503) on an agent comment reached the model as invalid_args and was audited so. Only a 4xx refusal is translated now; a coded 5xx stays a plain error and answers `error`.
…ence A blank or whitespace-only title at the tool door still answered the generic 'needs a non-empty "title" string', naming neither the range nor its unit. It now answers taskTitleRefusal's empty sentence, the one the domain's validateTitle throws; a missing or non-string title keeps the generic text.
The tasks door's schema carried caps of its own above the domain's (a
title up to 500, a description up to 50,000, up to 100 labels, a comment
min(1)), and anything it refused answered a bare `invalid body` that
could not tell an empty title or comment from an over-long one. The
title, description, label count and comment body are now checked with
the domain's own refusal helpers and answer `{error: <code>, message}`,
before a rate-limit slot is spent.
A task refusal's sentence now reaches the app door and an agent's tool result, yet SETUP_FOLDER_MISSING echoed the setup folder name it was sent. The sentence names the rule instead, and a guard reads every TaskError, TaskReviewError and task-domain ProjectError message so a new interpolated value fails until it is made static or reviewed.
The REST reference and the house schema messages said "characters" for the task title, description, label, comment and translation caps, which count UTF-16 code units like the domain's refusals. The schema messages and the en/de/fr reference now name the unit.
The row for named task limits now covers the app door's schema, the empty task_create title, a coded outage staying `error`, the value-free setup-folder refusal with its guard, and REST's unit wording.
yannickmonney
left a comment
There was a problem hiding this comment.
Needs correction before acceptance at daeb430451833d56ce1d085198b3cbb16c0cb8bd.
P2: serialize erasure handover with reviewer changes and review decisions. backend/domains/erasure/service.ts:1189 calls the retarget helper inside plain READ COMMITTED sql.begin. The task and approval reads take no locks. I reproduced two overlaps in isolated real Postgres using this exact helper and a rival SERIALIZABLE transaction:
- A newer reviewer assignment commits first; erasure then overwrites the pending approval back to the creator. The final task reviewer is
new-reviewer, whileapproval.metadata.requestedForiscreator. - A review completes first; the guarded update at
tasks/reviews.ts:301updates zero rows, but the helper still callsnotifyTaskReviewRequestedfor the completed approval.
Use the existing serializable retry wrapper (or equivalent locking/re-read), and only publish routing side effects for pending rows actually updated. Add deterministic barrier tests for both overlaps. The local harness uses real SQL with mocked membership/notification seams; it is not a full HTTP erasure test.
P2: publish a task invalidation when erasure changes review routing. The handover at erasure/service.ts:1201 bypasses recordActivity and emits only notification hints. Board and review reads are under the task query prefix, so an already-open board can keep stale designation/review chips and Needs my review results while its bell updates. Emit a task hint for handed-over tasks and cleared designations without pending reviews. This second finding is traced through producer/consumer code, not browser-verified; include a local two-session check.
Independent verification: 66 server and 7 client tests passed in fresh direct Vitest runs. The two real-Postgres probes confirmed the faulty outcomes. The CI platform unit job was a cache miss and actually executed; green status alone was not treated as proof. No production testing or writes were performed for this review.
An erasure moved an archived task's waiting review to the creator with an actionable bell and email, for a card hidden from the board. Archiving closes no gate, so the routing still moves (a restore must not bring back a review waiting on nobody), but `retargetPendingTaskReview` now takes `silent`, and the erasure passes it for an archived task. A hand-over that threw failed the whole reviewDecisions pass. The subject's id then stayed on every later designation and on past decisions, and each retry failed the same way. Now the failure is logged. The designation is still cleared and hinted in a transaction of its own, and the waiting row falls to the pseudonym, as it did before hand-overs existed. The integration check now also asserts that the erasure hints the task.
While `listAccessibleUserIds` was in flight, `useAssignableActors` fell back to every member of the organization, so the Reviewer picker offered editors outside a team-restricted project whom the server refuses. The hook now says when its narrowing has happened (`scopeReady`), and the Reviewer picker lists nobody and reads "Loading..." until it has. The assignee picker and mentions keep the fallback.
PROJ-B9 now provokes the refusal toast through a stale picker (a team removal hints `team`, not the project audience). The console request uses the organization ID rather than the slug and says where to copy both IDs. The automation row now claims only the helper, and the task dialog's toast stays manual. PROJ-F34's row covers the archived-task hand-over and the failure fall-through. BL-3 records the pending reviews an older erasure left waiting on the pseudonym, and how to recover them.
yannickmonney
left a comment
There was a problem hiding this comment.
Rechecked the correction at 9c0ded96d7ebe5759305268b8cfc1b593cac85a0. The two findings in my earlier review are addressed in the reviewed code paths:
- The designation clear, current task read, pending-recipient recheck, handover, and task hint now share
transactSerializable. Discovery no longer clears designations before that transaction. A review already moved away from the erased subject is skipped on the fresh attempt. - A task hint is emitted for a cleared designation or a pending handover, including a cleared task with no pending review.
Fresh direct tests at this head: 5 relevant server files, 67 passed. I also reran the two deterministic real-Postgres interleavings using the exact-head retry wrapper and retarget helper, with the caller's new clear/read/recheck sequence against minimal real tables. Both passed: the newer reviewer remains the recipient, and a concurrently completed review gets no new request; each conflicting handover retried once.
Evidence limit: those two scratch probes test the transaction sequence, not the entire processErasure HTTP/background workflow, and the task hint has not been checked across two live browser sessions here. The committed lifecycle tests cover the wrapper/hint and a reassignment before the transaction, but please retain equivalent barrier-driven concurrency regressions in the repository so these particular overlaps stay covered. This follow-up clears my reported code defects; it is not a full release/merge approval.
yannickmonney
left a comment
There was a problem hiding this comment.
Bounded follow-up on the four commits after the previously reviewed 9c0ded9, at 4097fa0.
The assigned reviewer inspected archived-task notification suppression, failed-handover fall-through, project-specific eligibility readiness and the added real-Postgres race test source. No substantive new source finding in this delta. Fresh direct runs passed 47/47 affected lifecycle, retarget, picker and actor-directory tests. The failed-handover fallback condition preserves a newer reviewer designation, while silent archived routing keeps subscription/dismissal effects without sending a new notification.
The new full-service Postgres probes were source-reviewed but not executed in this follow-up; the earlier two real-Postgres overlap results belong to 9c0ded9. No full root gate, SAST or browser loading/error-state run was repeated. GitHub currently reports merge conflicts, so the conflict-resolution head needs its own review and validation. This is not a whole-PR approval or merge.
Merge 066d510 pulled the head of the still-open #3538 (fix/app-door-refusals-name-field) into this branch, so the squash of #3554 would have landed that PR's field-naming work under the reviewer title. This reverts the merge against its first parent, leaving the tree exactly as the reviewer fixes had it at 4d2cf36. #3538 lands on its own.
Takes main up to 207883c and recounts the manual suites main grew.
Problem
Follow-ups left open by #3517 (changing the reviewer re-targets the pending review):
reviewDecisionserasure pass rewrote a pending review'srequestedFortoerased-user, so the review waited on nobody: no board chip, no Needs my review, no bell.Change
backend/domains/tasks/reviews.tsreviewerEligibility(tx, {organizationId, projectTeamIds, userId})→eligible | not_member | cannot_edit. It is the single rule:resolveRevieweruses it, and designation is checked against it.resolveReviewercan now exclude one person from every slot of the chain.retargetPendingTaskReview,actorUserIdis optional. When it is absent, the request is sent as thesystemsubmitter. It also takes a newexcludeUserId.backend/domains/erasure/service.ts(reviewDecisionspass):retargetPendingTaskReviewtakessilent, which keeps the follow and skips the request bell and email for a card hidden from the board.console.error, the designation is still cleared and hinted in a transaction of its own, and the waiting row falls to the pseudonym, as it did before hand-overs existed. Routing can no longer keep the subject's id on later tasks or on past decisions.TASK_NOT_FOUNDis caught, not swallowed), that was decided in the meantime, or whose hand-over failed.backend/domains/collab/service.tsdismissReviewerAssignedNotifications: marks the former designee's unread heads-up on that task read and sends them a bell hint.{kind: 'system'}review submitter. It uses the existingtaskReviewRequestedBodyHumancopy andactor_type = 'system'.backend/domains/tasks/service.ts(updateTask)TASK_REVIEWER_NO_EDIT_ACCESS(or the existingTASK_REVIEWER_INVALIDfor a non-member) before anything is written.useAssignableActorsnow exposesscopeReady. Until the project's audience has loaded, the Reviewer picker lists nobody and readscommon.actions.loading, where it used to fall back to every org editor. The assignee picker and mentions keep that fallback.reviewer-picker.test.tsxcovers the role filter and the loading state, anduse-actor-directory.test.tscovers the team-restricted narrowing.tasks.reviewer.editorsOnly) as a toast instead of the generic error, viaapp/features/tasks/lib/reviewer-refusal.ts.TASK_REVIEWER_NO_EDIT_ACCESSis added to the app-only list inrest/error-codes.test.ts; REST carries no reviewer.admin/governance/data-subject-requests.md): one paragraph on what erasure does to reviewer designations, waiting reviews and past decisions.projects/tasks.mdalready says only project editors can be reviewers.PROJ-F33(heads-up dismissed before review),PROJ-F34(an erased reviewer's waiting review moves on) andPROJ-B9(only an editor can be the reviewer), plus theirreference/automation.mdrows.reference/error-codes.mdrow for the refusal.readme.mdcounts the three new boxes (projects 49 → 52);aa95295bbthen recounts the whole inventory from the suites (876), which also corrects six rows main had let drift.No schema change, no migration, no contract change.
Verification
Scope (review round 2). Merge
066d510abhad pulled the head of fix(platform): name the refused field at the app doors and in forms #3538 (fix/app-door-refusals-name-field, then still open) into this branch, which grew the diff to about 100 files.203742c9areverts that merge against its first parent, so the tree is exactly4d2cf36fbagain.58986ce95and658b4f8cdthen merge main up to9662e8a5c, which by then carried fix(platform): name the refused field at the app doors and in forms #3538 as its own squash (df5bc9264). The PR now changes 27 files, all of them the reviewer work listed above, and depends on no other open PR. On658b4f8cd: platformtsc --noEmitclean; server tests overbackend/domains/{tasks,collab,erasure,approvals,projects}/,backend/jobs/,backend/rest/{error-codes,v1-tasks,v1-tasks.review}.test.ts: 65 files, 549 tests pass;--project client app/features/tasks: 44 files, 268 tests pass; scopedoxlint --type-aware --type-check: clean;bun run lint:manual: ok.Committed concurrent-write regressions:
backend/domains/erasure/review-handover.integration.ts, registered ascheckErasureReviewHandoverRaces, runs full productionprocessErasurewhile a SQL barrier allows productionupdateTaskorupdateTaskStatusto commit against its earlier snapshot. It asserts that a newer reviewer remains the recipient and that an already completed review receives no stale request. Fresh real Postgres: 19/19 including harness checks, with one serialization retry in each race. With exact originaldaeb4304erasure service and the same tests: 17/19, failing both races (approval overwritten to creator; stale request sent after completion). Full platform typecheck, scoped type-aware lint and manual guard pass.Review round 1. Server: 61 files, 514 tests. Client
app/features/tasks/: 44 files, 262 tests.tsc --noEmitand scoped type-aware oxlint are clean. The new cases (silent retarget, archived hand-over, failed hand-over, picker loading state, hook narrowing) fail against the previous source. Real Postgres and MinIO, fresh, four lanes: 42/42. The erasure check now also asserts ataskoutbox hint for the handed-over task; with the pre-round-1 erasure service it readstask hints=0.Final review validation. Fresh server regression run: 36 files, 260 tests; task picker/refusal UI: 2 files, 7 tests. After merging the latest main, the erasure, reviewer, retarget, activity, collaboration and error-code suites passed again: 6 files, 68 tests. Platform typecheck, scoped type-aware lint and manual-layer checks pass.
Erasure race regression. The lifecycle test verifies serializable isolation, clearing before handover, and the task realtime hint in the transaction; it fails against the original nonserializable implementation. A second test verifies that a review reassigned after discovery is left with its new reviewer and emits no spurious task hint.
Unit tests.
bunx vitest run --project serveroverbackend/domains/{tasks,collab,erasure,approvals,projects}/,backend/jobs/,backend/rest/{error-codes,v1-tasks,v1-tasks.review}.test.ts: 57 files, 471 tests pass.--project client app/features/tasks/: 44 files, 258 tests pass.The new tests fail without the source change. With the four source files stashed, 16 of them fail:
collab/service.test.ts: dismissal ×2, system submitter.erasure/service.lifecycle.test.ts: review pass hand-over.tasks/reviews.retarget.test.ts: exclusion ×2,reviewerEligibility×4.tasks/service.reviewer.test.ts: refusal, heads-up dismissal ×3, and the two re-mocked designation cases.reviewer-refusal.test.tscannot resolve its module.Real Postgres (my own
tale-db+ MinIO containers),ITEST_LANES=checkFiles,checkTasksCollabIntegrity,checkReviewArc,checkErasure. The integration check gains three assertions: a read-only member is refused with nothing written or rung, the heads-up is dismissed on move and on clear, and after erasure the waiting review belongs to the creator with an unread system bell.pending/erased-userwith no creator bell.backend:integrationis not a CI job, so this local run is the real-Postgres proof.Lint and other checks.
bunx oxlint --type-aware --type-checkon every changed file: clean. The pre-commit hook applied oxfmt and opengrep.bun run lint:manual: ok.check-guide.tsonsuites/projects.md: OK. Docs suite (services/docs,bunx vitest run): 34 files, 166 tests pass, with no report-mode findings on the edited pages.Left open
PROJ-F33,PROJ-F34andPROJ-B9have not been run by hand in a browser yet. The two live bells and the post-erasure board chip are manual per their automation rows.requestedFor: 'erased-user'are not repaired, and they still wait on nobody. No backfill ships: the reviewer chain checks membership and project access in code, so a SQL repair would be a second copy of it. This is recorded asBL-3intests/manual/reference/not-a-finding.md, with the recovery: set a Reviewer on the task, which moves the open review to that person, and clear it again to hand it to the creator.PROJ-B9now reaches it by hand through a stale picker: a team removal hintsteam, not the project audience.