title: "Scaffold the task module and its resources"
context: |
Build a `task` domain: users own the tasks they create; admins manage any.
Tasks self-nest into subtasks (parent + children). A task may be assigned to a
user, but the assignee link never grants ownership. Auth is owner-or-admin on
every mutation. If `modules/task/` already exists, this work is void — do not run.
goal: |
Create the `task` module + needed resources, wired owner-or-admin on mutations.
## Notes
- If `modules/task/` exists, STOP and report. Else `/module:create` task, then
build each resource via its `*:create` skill (`--module=task`), respecting
controllers → services → repositories → entities, registering all.
- Judge each resource; create the justified, skip the rest with a reason.
Defaults: entity + repository always; service + controller per use case;
permission always (owner-or-admin on update/delete, reuse the permission
service); migration/seed/event/translation/queue only if applicable; storage
skip (attachments belong on a file module); workflow skip (status moves
freely, nothing to roll back).
- Guard against cycles: a task may not be its own ancestor.
- The assignee is a plain reference, not an owner — it grants no update/delete.
- Throw typed exceptions (e.g. `TaskNotFoundException`), never return null.
### Data Model
- `Task.owner` ↔ `User.tasks` — ManyToOne / OneToMany
- `Task.parent` ↔ `Task.children` — self-referential ManyToOne / OneToMany
- `Task.assignee` ↔ `User.assignedTasks` — ManyToOne / OneToMany (nullable)
dod: |
- [ ] Aborts with a report if `modules/task/` exists
- [ ] `task` module created and registered into the app and `SharedModule`
- [ ] `Task` entity with fields: `title`, `slug` (unique), `description`,
`icon`, `color` (`SimpleColorType`), `status` (`StatusType`, pending →
active → done), `priority` (low → medium → high), `position`, `dueDate`,
`completedAt`, `lang` (`LocaleType`), `parent` (nullable), `children`,
`assignee` (nullable), `owner`, `createdAt`, `updatedAt`
- [ ] Full CRUD; user mutates only their own, admin any; non-owner/non-admin
rejected
- [ ] Assignment grants no update/delete rights
- [ ] Tree-cycle updates rejected
- [ ] If queues are used, task mutations run through a queue
- [ ] Unneeded resources skipped and reported with a reason
- [ ] `bun run fmt`, `bun run lint`, `bun run test` pass from the root