Skip to content

fix(platform): close tasks/collab authz, orphan, and notification gaps - #3180

Merged
larryro merged 1 commit into
mainfrom
fix/tasks-collab-integrity
Sep 4, 2026
Merged

larryro merged 1 commit into
mainfrom
fix/tasks-collab-integrity

Conversation

@larryro

@larryro larryro commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Seven verified medium findings in the task board's authorization, delete, review-gate and notification seams, from the backend deep-review campaign (/tmp/tale-review/triage/mediums.md, modules tasks + collab). Base 899fcc08a (has #3130 / #3157 / #3158 / #3164); every finding was re-verified live on that base before the fix. One commit per seam.

Per-finding outcome

# Finding Outcome Evidence
1 Run-cancel route never checks the run belongs to the authorized task (tasks/routes.ts cancel by :runId) fixed — b97e14b74 Route resolves the run and answers the opaque 404 AGENT_RUN_NOT_FOUND when it is not this task's; cancelAgentRunInTx binds task_id inside the UPDATE predicate (no unbound cancel door left).
2 Task hard delete orphans attachment/output blobs and live runs (deleteTask TODO) fixed — 954214d2e Subtree's live agent runs cancelled through the ledgered in-tx door before the FK cascade, bound automation runs through cancelRunInTx; the tasks' unbound file_metadata rows are trashed for refs no surviving task lists and the durable knowledge.release_refs job (#3140 seam) deletes the bytes after commit.
3 Single-card reassign ignores live runs while bulk enforces the gate fixed — 0cb174b4e One pure assigneeChanges rule for assignTask and bulkUpdateTasks; the single door refuses TASK_HAS_LIVE_RUN (409), bulk keeps skipping; every picker names the refusal (en/de/fr). The comment-mention dispatcher only reaches assignTask with no live run (steer lane returns first), so it is unaffected.
4 Bulk moves and external closes park tasks in_review without minting the review gate fixed — ea58c2fa3 requestTaskReview now runs from the bulk bar, the non-workflow external close, and agentUpdateTaskStatusTrusted (the agent's task_update_status tool + the workflow native, which also parked without a gate). Lanes without a run key mint on the task's live run so the settle replay finds the same row; idempotent.
5 Reviewer-designation heads-up notification never fires in 0.5 fixed — 67501dd96 Live notifyTaskReviewerAssigned in collab/service.ts (bell only, pref gate skipped like the request, never for yourself) on the notification hint entity from #3164; updateTask subscribes the designee (reason reviewer) and refuses a non-member (TASK_REVIEWER_INVALID).
6 Mention directory swallows listing failures — @mentions silently become plain text fixed — 6bfb0f7a2 Each leg throws MentionDirectoryError; the task-comment door answers 503 MENTION_DIRECTORY_UNAVAILABLE instead of posting a comment that notified nobody.
7 Attention summary drops reviews when org has >100 pending approvals (both duplicate records) fixed — edd19cb38 requestedFor + project scope filtered in SQL before the cap, ORDER BY seq DESC, exact total via window count; unread counts from a GROUP BY aggregate instead of a capped page (badge now exact rather than capped at 100).

No migration needed (0070/0071 untouched): the pending-review filter rides approvals_org_status, and pending reviews are rare org-wide.

Tests (red on base, green on branch)

Colocated vitest, each observed failing before its fix:

  • tasks/agent-runs.test.ts — the cancel binds task_id in the guard; a refused cancel writes no ledger entry (2, red: no cancelAgentRunInTx).
  • tasks/service.test.ts — assigneeChanges transfer rule + the 409 refusal (4).
  • tasks/service.blobs.test.ts — collectTaskBlobRefs across a subtree, de-dup, malformed rows (3, red: no export).
  • collab/service.test.ts — notifyTaskReviewerAssigned writes the row + bell hint with no pref gate, skips self (2, red); attention summary filters requestedFor in SQL, exact counts (2, red on the JS filter).
  • collab/mention-directory.test.ts — a failed member/automation listing rejects (2, red: "promise resolved instead of rejecting"), healthy directory still resolves.

Integration (backend/integration-check.ts, new checkTasksCollabIntegrity, 8 probes): foreign-door cancel refused 404 + own door cancels once with one ledger row; bulk → In review mints the gate the leave-to-done resolves (completed/approve); external close parks WITH the gate; agent-tool park run-keyed + settle replay finds it (1 row), workflow park mints an automation row; hard delete → children gone, agent run ledgered cancelled, automation run cancelled, deliverable blob gone from MinIO via the release job, file row reaped; reviewer designation → bell + subscription + notification hint, self silent, non-member 400; mention directory leg down → MENTION_DIRECTORY_UNAVAILABLE/503/agents; the caller's review found behind 120 other pending reviews with the exact count, org-wide and project-scoped.

Verification (observed)

  • bunx tsc --noEmit (platform): clean after every seam.
  • bun run --filter @tale/platform lint: exit 0.
  • bunx vitest --run --project server --project pii: 72,736 tests pass; 3 app/routes/*.test.tsx files fail to LOAD with Denied ID …@fontsource/inter…woff2?url — the known worktree + symlinked node_modules symptom, also on base, unrelated.
  • backend:integration on fresh throwaway tale-db + MinIO (SANDBOX_LLM_GATEWAY_ADMIN_PASSWORD set), branch: 387/387 checks passed, all 8 new probes PASS.
  • Same suite with the branch probes over the BASE sources (fresh containers): 379/387 — every pre-existing check green, exactly the 8 new probes red with the defect signatures (foreign-door cancel answered 200 and killed the other task's run; 0 gate rows on bulk / external / tool / workflow parks; hard delete left the automation run running and the blob + live file row behind with no ledger entry; no reviewer bell/subscription and a non-member accepted; degraded directory "resolved"; the caller's review missing behind the 120 others).

Cross-class discoveries (not fixed here)

  • core/collab/notify_task_reviews.ts and most of core/tasks/review_shared.ts are dead Convex-shim code still compiled by the platform tsconfig; only REVIEW_POLICY_REFUSAL_CODES is live. Cleanup candidate.
  • The /api/app/collab/attention summary has no caller under app/ that I could find; its unread counts are now exact instead of capped at 100 — worth confirming the badge consumer (if any) renders large counts.
  • TaskError now admits status 409 (previously 400|403|404).

Squash of the wt-3 batch for rebase onto main; the PR body carries the per-finding record.
@larryro
larryro force-pushed the fix/tasks-collab-integrity branch from a5fac7e to 051bda2 Compare September 4, 2026 03:29
@larryro
larryro marked this pull request as ready for review September 4, 2026 03:29
@larryro
larryro merged commit 4673e0a into main Sep 4, 2026
23 checks passed
@larryro
larryro deleted the fix/tasks-collab-integrity branch September 4, 2026 03:34
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.

1 participant