Skip to content

moooon

Motir

Vibe your whole project. Bring an idea — Motir's three AI layers plan it, track it, and ship it, end to end. You're looking at Motir, built in Motir.

  • Vibe Project
  • Open Source
  • AI Agent
  • AI Loop
1
requests
0
upvotes
145
planned
1,361
shipped

Motir · Work items

MOTIR-793Done

2.8.2 Service + repo — deleteWorkItem (permission-gated, subtree cascade, link cleanup, audit)

Estimate: 70m · Type: code

Service + repository for permanent delete with subtree cascade. Add workItemsService.deleteWorkItem(id, ctx): permission-gated (a delete capability — mirror Jira "Delete Issues"; reuse the project-admin / 6.4 gate), in ONE $transaction: resolve the full descendant set (the kind-parent tree), remove all their work-item links (from + reciprocal), delete the rows (children-before-parent / DB cascade), and write an audit record (an activity/audit entry — the rows themselves are gone). Translate races (already-deleted / concurrent move) to typed errors. Repo methods are single-op (workItemRepository.deleteSubtree / findDescendantIds); service owns the transaction.

Acceptance criteria

  • deleteWorkItem permanently removes the item + ALL descendants + their links in one transaction; permission-gated; typed errors for races; auditable.
  • No orphaned links/rows; idempotent-safe on a missing id (typed WorkItemNotFoundError).
  • Unit/integration coverage (cascade, links, permission, race) — per-file coverage gate on touched core files.

Context refs

  • lib/services/workItemsService.ts (archiveWorkItem shape to mirror; updateWorkItem tx pattern), lib/repositories/workItemRepository.ts (descendant/forest reads), workItemLinkRepository.delete; CLAUDE.md 4-layer + lock-before-read-derived