# Tasks — MS21 Multi-Tenant RBAC Data Migration

> Single-writer: orchestrator (Jarvis/OpenClaw) only. Workers read but never modify.
> Schema: id | status | milestone | description | issue | repo | branch | depends_on | blocks | agent | started_at | completed_at | estimate | used | notes

| id             | status      | milestone | description                                                                       | issue    | repo  | branch                         | depends_on                                                  | blocks                     | agent           | started_at | completed_at | estimate | used | notes                                                                                                                 |
| -------------- | ----------- | --------- | --------------------------------------------------------------------------------- | -------- | ----- | ------------------------------ | ----------------------------------------------------------- | -------------------------- | --------------- | ---------- | ------------ | -------- | ---- | --------------------------------------------------------------------------------------------------------------------- |
| MS21-PLAN-001  | done        | phase-1   | Write PRD, init mission, populate TASKS.md                                        | TASKS:P1 | stack | chore/ms21-init                | —                                                           | MS21-DB-001                | orchestrator    | 2026-02-28 | 2026-02-28   | 10K      | 12K  | PR #552, CI green                                                                                                     |
| MS21-DB-001    | done        | phase-1   | Prisma migration: add user fields                                                 | TASKS:P1 | api   | feat/ms21-schema               | MS21-PLAN-001                                               | MS21-API-001               | claude-worker-1 | 2026-02-28 | 2026-02-28   | 10K      | 9K   | PR #553, CI green                                                                                                     |
| MS21-API-001   | done        | phase-1   | AdminModule with user/workspace admin endpoints                                   | TASKS:P1 | api   | feat/ms21-admin-api            | MS21-DB-001                                                 | MS21-TEST-001              | claude-worker-2 | 2026-02-28 | 2026-02-28   | 20K      | 18K  | PR #555, CI green                                                                                                     |
| MS21-API-002   | done        | phase-1   | Admin user endpoints (list, invite, update, deactivate)                           | TASKS:P1 | api   | feat/ms21-admin-api            | MS21-DB-001                                                 | MS21-TEST-001              | claude-worker-2 | 2026-02-28 | 2026-02-28   | —        | —    | Combined with API-001                                                                                                 |
| MS21-API-003   | done        | phase-1   | Workspace member management endpoints                                             | TASKS:P1 | api   | feat/ms21-workspace-members    | MS21-DB-001                                                 | —                          | codex-worker-1  | 2026-02-28 | 2026-02-28   | 15K      | 14K  | PR #556, CI green                                                                                                     |
| MS21-API-004   | done        | phase-1   | Team management module                                                            | TASKS:P1 | api   | feat/ms21-teams                | MS21-DB-001                                                 | —                          | codex-worker-2  | 2026-02-28 | 2026-02-28   | 15K      | 13K  | PR #564, CI green                                                                                                     |
| MS21-API-005   | done        | phase-1   | Admin workspace endpoints                                                         | TASKS:P1 | api   | feat/ms21-admin-api            | MS21-DB-001                                                 | —                          | claude-worker-2 | 2026-02-28 | 2026-02-28   | —        | —    | Combined with API-001                                                                                                 |
| MS21-TEST-001  | done        | phase-1   | Unit tests for AdminService and AdminController                                   | TASKS:P1 | api   | feat/ms21-admin-api            | MS21-API-001                                                | —                          | claude-worker-2 | 2026-02-28 | 2026-02-28   | 15K      | —    | PR #555, 26 tests                                                                                                     |
| MS21-FIX-001   | done        | phase-1   | Fix flaky CI tests (rate limit timeout + log sanitizer)                           | TASKS:P1 | api   | fix/ms21-flaky-ci              | MS21-API-001                                                | —                          | codex-worker-3  | 2026-02-28 | 2026-02-28   | 8K       | 7K   | PR #562, CI green                                                                                                     |
| MS21-AUTH-001  | done        | phase-2   | LocalAuthModule: break-glass auth                                                 | TASKS:P2 | api   | feat/ms21-local-auth           | MS21-DB-001                                                 | MS21-TEST-002              | claude-worker-3 | 2026-02-28 | 2026-02-28   | 20K      | 19K  | PR #559, CI green                                                                                                     |
| MS21-AUTH-002  | done        | phase-2   | Break-glass setup endpoint                                                        | TASKS:P2 | api   | feat/ms21-local-auth           | MS21-AUTH-001                                               | —                          | claude-worker-3 | 2026-02-28 | 2026-02-28   | —        | —    | Combined with AUTH-001                                                                                                |
| MS21-AUTH-003  | done        | phase-2   | Break-glass login endpoint                                                        | TASKS:P2 | api   | feat/ms21-local-auth           | MS21-AUTH-001                                               | —                          | claude-worker-3 | 2026-02-28 | 2026-02-28   | —        | —    | Combined with AUTH-001                                                                                                |
| MS21-AUTH-004  | not-started | phase-2   | Deactivation session invalidation                                                 | TASKS:P2 | api   | feat/ms21-session-invalidation | MS21-AUTH-001                                               | —                          | —               | —          | —            | 10K      | —    | Deferred; do after Phase 4                                                                                            |
| MS21-TEST-002  | done        | phase-2   | Unit tests for LocalAuth                                                          | TASKS:P2 | api   | feat/ms21-local-auth           | MS21-AUTH-001                                               | —                          | claude-worker-3 | 2026-02-28 | 2026-02-28   | 15K      | —    | PR #559, 27 tests                                                                                                     |
| MS21-MIG-001   | done        | phase-3   | Migration script: scripts/migrate-brain.ts                                        | #568     | api   | feat/ms21-migration            | MS21-DB-001                                                 | MS21-MIG-002,MS21-TEST-003 | codex-worker-1  | 2026-02-28 | 2026-02-28   | 25K      | 22K  | PR #554                                                                                                               |
| MS21-MIG-002   | done        | phase-3   | Migration mapping: status/priority/domain                                         | #568     | api   | feat/ms21-migration            | MS21-MIG-001                                                | —                          | codex-worker-1  | 2026-02-28 | 2026-02-28   | —        | —    | Included in MIG-001                                                                                                   |
| MS21-TEST-003  | done        | phase-3   | Migration script unit tests (9/9 passing)                                         | #568     | api   | test/ms21-migration-tests      | MS21-MIG-001                                                | —                          | codex           | 2026-02-28 | 2026-02-28   | 20K      | 17K  | PR #566 merged, CI green. Review: 0 blockers, 2 should-fix (brittle harness), 0 sec issues.                           |
| MS21-MIG-003   | not-started | phase-3   | Run migration on production database                                              | #568     | api   | —                              | MS21-MIG-001,MS21-TEST-003                                  | MS21-VER-001               | —               | —          | —            | 5K       | —    | Needs deploy coordination; not automatable                                                                            |
| MS21-MIG-004   | done        | phase-3   | Import API endpoints (6/6 tests)                                                  | #568     | api   | feat/ms21-import-api           | MS21-DB-001                                                 | —                          | codex           | 2026-02-28 | 2026-02-28   | 20K      | 24K  | PR #567 merged, CI green. Review: 0 blockers, 4 should-fix, 1 medium sec (no audit log).                              |
| MS21-UI-001    | done        | phase-4   | Settings/users page                                                               | #569     | web   | feat/ms21-ui-users             | MS21-API-001,MS21-API-002                                   | —                          | codex           | 2026-02-28 | 2026-02-28   | 20K      | ~30K | PR #573 merged. Review: 0 blockers, 4 should-fix → MS21-UI-001-QA                                                     |
| MS21-UI-001-QA | done        | phase-4   | QA: fix 4 review findings (pagination, error state, self-deactivate guard, tests) | #569     | web   | fix/ms21-ui-001-qa             | MS21-UI-001                                                 | —                          | —               | —          | —            | 15K      | —    | 0 blockers; merged per framework. Should-fix: pagination cap, error/empty collision, self-deactivate guard, no tests. |
| MS21-UI-002    | done        | phase-4   | User detail/edit and invite dialogs                                               | #569     | web   | feat/ms21-ui-users             | MS21-UI-001                                                 | —                          | —               | —          | —            | 15K      | —    |                                                                                                                       |
| MS21-UI-003    | done        | phase-4   | Settings/workspaces page (wire to real API)                                       | #569     | web   | feat/ms21-ui-workspaces        | MS21-API-003                                                | —                          | codex           | 2026-02-28 | 2026-02-28   | 15K      | ~25K | PR #574 merged. Review: 0 critical, 1 low (raw errors in UI)                                                          |
| MS21-UI-004    | done        | phase-4   | Workspace member management UI                                                    | #569     | web   | feat/ms21-ui-workspaces        | MS21-UI-003,MS21-API-003                                    | —                          | —               | —          | —            | 15K      | —    | Components exist                                                                                                      |
| MS21-UI-005    | done        | phase-4   | Settings/teams page                                                               | #569     | web   | feat/ms21-ui-teams             | MS21-API-004                                                | —                          | —               | —          | —            | 15K      | —    |                                                                                                                       |
| MS21-TEST-004  | done        | phase-4   | Frontend component tests                                                          | #569     | web   | test/ms21-ui                   | MS21-UI-001,MS21-UI-002,MS21-UI-003,MS21-UI-004,MS21-UI-005 | —                          | —               | —          | —            | 20K      | —    |                                                                                                                       |
| MS21-RBAC-001  | done        | phase-5   | Sidebar navigation role gating                                                    | #570     | web   | feat/ms21-rbac                 | MS21-UI-001                                                 | —                          | —               | —          | —            | 10K      | —    |                                                                                                                       |
| MS21-RBAC-002  | done        | phase-5   | Settings page access restriction                                                  | #570     | web   | feat/ms21-rbac                 | MS21-RBAC-001                                               | —                          | —               | —          | —            | 8K       | —    |                                                                                                                       |
| MS21-RBAC-003  | done        | phase-5   | Action button permission gating                                                   | #570     | web   | feat/ms21-rbac                 | MS21-RBAC-001                                               | —                          | —               | —          | —            | 8K       | —    |                                                                                                                       |
| MS21-RBAC-004  | done        | phase-5   | User profile role display                                                         | #570     | web   | feat/ms21-rbac                 | MS21-RBAC-001                                               | —                          | —               | —          | —            | 5K       | —    |                                                                                                                       |
| MS21-VER-001   | done        | phase-6   | Full quality gate pass                                                            | #571     | stack | —                              | MS21-TEST-004,MS21-RBAC-004,MS21-MIG-003                    | MS21-VER-002               | —               | —          | —            | 5K       | —    |                                                                                                                       |
| MS21-VER-002   | done        | phase-6   | Deploy and smoke test                                                             | #571     | stack | —                              | MS21-VER-001                                                | MS21-VER-003               | —               | —          | —            | 5K       | —    |                                                                                                                       |
| MS21-VER-003   | done        | phase-6   | Tag v0.0.21                                                                       | #571     | stack | —                              | MS21-VER-002                                                | —                          | —               | —          | —            | 2K       | —    |                                                                                                                       |

## Budget Summary

| Phase                  | Tasks  | Done   | Estimate  | Used      |
| ---------------------- | ------ | ------ | --------- | --------- |
| Phase 1 (Schema + API) | 9      | 9      | ~113K     | ~93K      |
| Phase 2 (Auth)         | 4      | 3      | ~45K      | ~19K      |
| Phase 3 (Migration)    | 5      | 3      | ~70K      | ~63K      |
| Phase 4 (UI)           | 6      | 0      | ~100K     | —         |
| Phase 5 (RBAC)         | 4      | 0      | ~31K      | —         |
| Phase 6 (Verification) | 3      | 0      | ~12K      | —         |
| **Total**              | **31** | **15** | **~371K** | **~175K** |

Remaining estimate: ~143K tokens (Codex budget).

## MS22 — Fleet Evolution (Phase 0: Knowledge Layer)

| id              | status | milestone    | description                                                  | issue    | repo  | branch                         | depends_on                                                | blocks        | agent        | started_at | completed_at | estimate | used | notes                                         |
| --------------- | ------ | ------------ | ------------------------------------------------------------ | -------- | ----- | ------------------------------ | --------------------------------------------------------- | ------------- | ------------ | ---------- | ------------ | -------- | ---- | --------------------------------------------- |
| MS22-PLAN-001   | done   | p0-knowledge | PRD + mission bootstrap + TASKS.md                           | TASKS:P0 | stack | feat/ms22-knowledge-schema     | —                                                         | MS22-DB-001   | orchestrator | 2026-02-28 | 2026-02-28   | 10K      | 8K   | PRD-MS22.md, mission fleet-evolution-20260228 |
| MS22-DB-001     | done   | p0-knowledge | Findings module (pgvector, CRUD, similarity search)          | TASKS:P0 | api   | feat/ms22-findings             | MS22-PLAN-001                                             | —             | codex        | 2026-02-28 | 2026-02-28   | 20K      | ~22K | PR #585 merged, CI green                      |
| MS22-API-001    | done   | p0-knowledge | Findings API endpoints                                       | TASKS:P0 | api   | feat/ms22-findings             | MS22-DB-001                                               | —             | codex        | 2026-02-28 | 2026-02-28   | —        | —    | Combined with DB-001                          |
| MS22-DB-002     | done   | p0-knowledge | AgentMemory module (key/value store, upsert)                 | TASKS:P0 | api   | feat/ms22-agent-memory         | MS22-DB-001                                               | —             | codex        | 2026-02-28 | 2026-02-28   | 15K      | ~16K | PR #586 merged, CI green                      |
| MS22-API-002    | done   | p0-knowledge | AgentMemory API endpoints                                    | TASKS:P0 | api   | feat/ms22-agent-memory         | MS22-DB-002                                               | —             | codex        | 2026-02-28 | 2026-02-28   | —        | —    | Combined with DB-002                          |
| MS22-DB-004     | done   | p0-knowledge | ConversationArchive module (pgvector, ingest, search)        | TASKS:P0 | api   | feat/ms22-conversation-archive | MS22-DB-001                                               | —             | codex        | 2026-02-28 | 2026-02-28   | 20K      | ~18K | PR #587 merged, CI green                      |
| MS22-API-004    | done   | p0-knowledge | ConversationArchive API endpoints                            | TASKS:P0 | api   | feat/ms22-conversation-archive | MS22-DB-004                                               | —             | codex        | 2026-02-28 | 2026-02-28   | —        | —    | Combined with DB-004                          |
| MS22-API-005    | done   | p0-knowledge | EmbeddingService (reuse existing KnowledgeModule)            | TASKS:P0 | api   | —                              | —                                                         | —             | orchestrator | 2026-02-28 | 2026-02-28   | 0        | 0    | Already existed; no work needed               |
| MS22-DB-003     | done   | p0-knowledge | Task model: add assigned_agent field + migration             | TASKS:P0 | api   | feat/ms22-task-agent           | MS22-DB-001                                               | MS22-API-003  | —            | —          | —            | 8K       | —    | Small schema + migration only                 |
| MS22-API-003    | done   | p0-knowledge | Task API: expose assigned_agent in CRUD                      | TASKS:P0 | api   | feat/ms22-task-agent           | MS22-DB-003                                               | MS22-TEST-001 | —            | —          | —            | 8K       | —    | Extend existing TaskModule                    |
| MS22-TEST-001   | done   | p0-knowledge | Integration tests: Findings + AgentMemory + ConvArchive      | TASKS:P0 | api   | test/ms22-integration          | MS22-API-001,MS22-API-002,MS22-API-004                    | MS22-VER-P0   | —            | —          | —            | 20K      | —    | E2E with live postgres                        |
| MS22-SKILL-001  | done   | p0-knowledge | OpenClaw mosaic skill (agents read/write findings/memory)    | TASKS:P0 | stack | feat/ms22-openclaw-skill       | MS22-API-001,MS22-API-002                                 | MS22-VER-P0   | —            | —          | —            | 15K      | —    | Skill in ~/.agents/skills/mosaic/             |
| MS22-INGEST-001 | done   | p0-knowledge | Session log ingestion pipeline (OpenClaw logs → ConvArchive) | TASKS:P0 | stack | feat/ms22-ingest               | MS22-API-004                                              | MS22-VER-P0   | —            | —          | —            | 20K      | —    | Script to batch-ingest existing logs          |
| MS22-VER-P0     | done   | p0-knowledge | Phase 0 verification: all modules deployed + smoke tested    | TASKS:P0 | stack | —                              | MS22-TEST-001,MS22-SKILL-001,MS22-INGEST-001,MS22-API-003 | —             | —            | —          | —            | 5K       | —    |                                               |

## MS22 Phase 1: DB-Centric Agent Fleet (reworked)

Design doc: `docs/design/MS22-DB-CENTRIC-ARCHITECTURE.md`

| Task ID  | Status | Phase    | Description                                                                                                           | Issue | Scope   | Branch                       | Depends On | Blocks          | Assigned Worker | Started | Completed | Est Tokens | Act Tokens | Notes |
| -------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------------- | ----- | ------- | ---------------------------- | ---------- | --------------- | --------------- | ------- | --------- | ---------- | ---------- | ----- |
| MS22-P1a | done   | phase-1a | Prisma schema: SystemConfig, BreakglassUser, LlmProvider, UserContainer, SystemContainer, UserAgentConfig + migration | —     | api     | feat/ms22-p1a-schema         | —          | P1b,P1c,P1d,P1e | —               | —       | —         | 20K        | —          |       |
| MS22-P1b | done   | phase-1b | Encryption service (AES-256-GCM) for API keys and tokens                                                              | —     | api     | feat/ms22-p1b-crypto         | —          | P1c,P1e,P1g     | —               | —       | —         | 15K        | —          |       |
| MS22-P1c | done   | phase-1c | Internal config endpoint: assemble openclaw.json from DB                                                              | —     | api     | feat/ms22-p1c-config-api     | P1a,P1b    | P1i,P1j         | —               | —       | —         | 20K        | —          |       |
| MS22-P1d | done   | phase-1d | ContainerLifecycleService: Docker API (dockerode) start/stop/health/reap                                              | —     | api     | feat/ms22-p1d-container-mgr  | P1a        | P1i,P1k         | —               | —       | —         | 25K        | —          |       |
| MS22-P1e | done   | phase-1e | Onboarding API: breakglass, OIDC, provider, agents, complete                                                          | —     | api     | feat/ms22-p1e-onboarding-api | P1a,P1b    | P1f             | —               | —       | —         | 20K        | —          |       |
| MS22-P1f | done   | phase-1f | Onboarding wizard WebUI (multi-step form)                                                                             | —     | web     | feat/ms22-p1f-onboarding-ui  | P1e        | —               | —               | —       | —         | 25K        | —          |       |
| MS22-P1g | done   | phase-1g | Settings API: CRUD providers, agent config, OIDC, breakglass                                                          | —     | api     | feat/ms22-p1g-settings-api   | P1a,P1b    | P1h             | —               | —       | —         | 20K        | —          |       |
| MS22-P1h | done   | phase-1h | Settings UI: Providers, Agent Config, Auth pages                                                                      | —     | web     | feat/ms22-p1h-settings-ui    | P1g        | —               | —               | —       | —         | 25K        | —          |       |
| MS22-P1i | done   | phase-1i | Chat proxy: route WebUI chat to user's OpenClaw container (SSE)                                                       | —     | api+web | feat/ms22-p1i-chat-proxy     | P1c,P1d    | —               | —               | —       | —         | 20K        | —          |       |
| MS22-P1j | done   | phase-1j | Docker entrypoint + health checks + core compose                                                                      | —     | docker  | feat/ms22-p1j-docker         | P1c        | —               | —               | —       | —         | 10K        | —          |       |
| MS22-P1k | done   | phase-1k | Idle reaper cron: stop inactive user containers                                                                       | —     | api     | feat/ms22-p1k-idle-reaper    | P1d        | —               | —               | —       | —         | 10K        | —          |       |

## MS22 Phase 2: Named Agent Fleet

PRD: `docs/PRD-MS22-P2-AGENT-FLEET.md`

| Task ID     | Status      | Phase    | Description                                  | Issue    | Scope | Branch                      | Depends On    | Blocks        | Assigned Worker | Started    | Completed  | Est Tokens | Act Tokens | Notes          |
| ----------- | ----------- | -------- | -------------------------------------------- | -------- | ----- | --------------------------- | ------------- | ------------- | --------------- | ---------- | ---------- | ---------- | ---------- | -------------- |
| MS22-P2-001 | done        | p2-fleet | Prisma schema: AgentTemplate, UserAgent      | TASKS:P2 | api   | feat/ms22-p2-agent-schema   | MS22-P1a      | P2-002,P2-003 | orchestrator    | 2026-03-04 | 2026-03-04 | 10K        | 3K         | PR #675 merged |
| MS22-P2-002 | done        | p2-fleet | Seed default agents (jarvis, builder, medic) | TASKS:P2 | api   | feat/ms22-p2-agent-seed     | P2-001        | P2-004        | orchestrator    | 2026-03-04 | 2026-03-04 | 5K         | 2K         | PR #677 merged |
| MS22-P2-003 | done        | p2-fleet | Agent template CRUD endpoints (admin)        | TASKS:P2 | api   | feat/ms22-p2-agent-crud     | P2-001        | P2-005        | orchestrator    | 2026-03-04 | 2026-03-04 | 15K        | 5K         | PR #678 merged |
| MS22-P2-004 | in-progress | p2-fleet | User agent CRUD endpoints                    | TASKS:P2 | api   | feat/ms22-p2-user-agents    | P2-002,P2-003 | P2-006        | orchestrator    | 2026-03-04 | —          | 15K        | —          |                |
| MS22-P2-005 | not-started | p2-fleet | Agent status endpoints                       | TASKS:P2 | api   | feat/ms22-p2-agent-api      | P2-003        | P2-008        | —               | —          | —          | 10K        | —          |                |
| MS22-P2-006 | not-started | p2-fleet | Agent chat routing (select agent by name)    | TASKS:P2 | api   | feat/ms22-p2-agent-routing  | P2-004        | P2-007        | —               | —          | —          | 15K        | —          |                |
| MS22-P2-007 | not-started | p2-fleet | Discord channel → agent routing              | TASKS:P2 | api   | feat/ms22-p2-discord-router | P2-006        | P2-009        | —               | —          | —          | 15K        | —          |                |
| MS22-P2-008 | not-started | p2-fleet | Agent list/selector UI in WebUI              | TASKS:P2 | web   | feat/ms22-p2-agent-ui       | P2-005        | —             | —               | —          | —          | 15K        | —          |                |
| MS22-P2-009 | not-started | p2-fleet | Unit tests for agent services                | TASKS:P2 | api   | test/ms22-p2-agent-tests    | P2-007        | P2-010        | —               | —          | —          | 15K        | —          |                |
| MS22-P2-010 | not-started | p2-fleet | E2E verification: Discord → agent → response | TASKS:P2 | stack | —                           | P2-009        | —             | —               | —          | —          | 10K        | —          |                |
