# Tasks: enterprise-api-plugin-social **Change ID**: enterprise-api-plugin-social **Package**: `@suaveplan/api-plugin-social` **Target path**: `api/comms/api-plugin-social` **Prerequisite packages on Verdaccio**: `@suaveplan/api`, `@suaveplan/api-shared`, `@suaveplan/api-plugin-auth`, `@suaveplan/api-plugin-database`, `@suaveplan/api-plugin-notifications`, `@suaveplan/events`, `@suaveplan/rate-limiter`, `@suaveplan/error` --- ## 0. Pre-flight (non-negotiable) - [ ] 0.1 Confirm clean working tree (`git status` reports nothing) and no in-flight worktrees with uncommitted work (`git worktree list` then `git status` in each) - [ ] 0.2 If any worktrees exist under `.claude/worktrees/`, account for each one: still-active agent, work-pending-merge, or stale-and-prune. Stale worktrees MUST be removed (`git worktree remove`) before opening a new one — code that has been lost twice on main is the failure mode this guards against. - [ ] 0.3 Confirm the package set in `MANIFEST.md` matches `find packages -maxdepth 3 -name package.json` count. Drift here means a prior change archived without regenerating the manifest. ## 1. Scaffold + types + errors + events - [ ] Create `api/comms/api-plugin-social/`; `package.json` v0.0.0; standard tooling. - [ ] Types: `Follow`, `FeedItem`, `Like`, `Comment`, `Block`, `Report`, `SocialPluginConfig` (Zod). - [ ] Errors: 6-code union + metadata + registration. Test + doc. - [ ] Events: `SocialEventMap` (social:followed, social:unfollowed, social:post:liked, social:comment:created, social:user:blocked). --- ## 2. SurrealQL - [ ] `follow.surql`, `feed_item.surql`, `like.surql`, `comment.surql`, `block.surql`, `report.surql`. tenantId + userId indexes. --- ## 3. Services (each `.test.ts` + `.md`) - [ ] **FollowService**: `follow`, `unfollow`, `listFollowers`, `listFollowing`, `isFollowing`. Notify via `api-plugin-notifications`. - [ ] **FeedService**: `getFeed(userId)` — fan-out on write; fanout limit configurable (default 1000 followers); paginated. - [ ] **LikeService**: `like`, `unlike`, `getLikeCount`, `isLiked`. Idempotent. - [ ] **CommentService**: `createComment`, `deleteComment`, `listComments` (threaded, paginated). - [ ] **BlockService**: `block`, `unblock`, `isBlocked` — hide from feed + follow from blocked user. - [ ] **ReportService**: `reportContent`, `listReports` (admin), `resolveReport`. --- ## 4. Routes - [ ] `POST/DELETE /social/follow/:userId` — `requireAuth` + rate-limit. - [ ] `GET /social/followers`, `GET /social/following` — `requireAuth`. - [ ] `GET /social/feed` — `requireAuth`. - [ ] `POST/DELETE /social/posts/:id/like` — `requireAuth` + rate-limit. - [ ] `GET/POST /social/posts/:id/comments`, `DELETE /social/comments/:id` — `requireAuth`. - [ ] `POST /social/block/:userId`, `DELETE /social/block/:userId` — `requireAuth`. - [ ] `POST /social/report` — `requireAuth`. - [ ] Route `.test.ts` + `.md`. --- ## 5. Plugin factory + integration tests + publish - [ ] `createSocialPlugin`: `definePlugin`, `dependencies: ["database", "auth"]`, `migrationsPath: "./surql"`. - [ ] Integration: follow → feed item appears → like → unlike → block hides from feed (real SurrealDB). - [ ] `bunx turbo lint typecheck test --filter=@suaveplan/api-plugin-social` — green; 100% coverage. - [ ] `bun scripts/publish.ts --package @suaveplan/api-plugin-social`. - [ ] Archive → `openspec/archive/2026-04-24-enterprise-api-plugin-social/`.