docs: archive stale mission state, scaffold CLI unification mission
Prior sessions left three different missions spread across the docs: - docs/MISSION-MANIFEST.md: Harness Foundation (complete) - docs/TASKS.md: Storage Abstraction Retrofit (P1-P4 done, P5 pending) - docs/scratchpads/mvp-20260312.md: MVP mission (stale) Reset the working state to a single clean mission focused on what actually needs to happen next: unify the mosaic CLI, add first-class commands for every sub-package, fix the gateway bootstrap token recovery dead-end, and stitch the install UX end-to-end. Changes: - Move Harness Foundation manifest + PRD to docs/archive/missions/harness-20260321/ - Move Storage Abstraction TASKS.md to docs/archive/missions/storage-abstraction/ - Scaffold new docs/MISSION-MANIFEST.md for cli-unification-20260404 with 8 milestones (M1 done via PR #398, M2 in-progress via this PR) - Scaffold new docs/TASKS.md with per-milestone task breakdown, dependencies, agent assignments, and token estimates - Scaffold docs/scratchpads/cli-unification-20260404.md with full planning decisions, gateway bootstrap bug root cause analysis, telemetry architecture notes, and open risks Left intact: - docs/PRD.md (v0.1.0, 1005 lines) — still the long-term target - docs/PRD-TUI_Improvements.md — active TUI work - docs/scratchpads/* historical task scratchpads — append-only breadcrumbs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,70 +1,70 @@
|
|||||||
# Mission Manifest — Harness Foundation
|
# Mission Manifest — CLI Unification & E2E First-Run
|
||||||
|
|
||||||
> Persistent document tracking full mission scope, status, and session history.
|
> Persistent document tracking full mission scope, status, and session history.
|
||||||
> Updated by the orchestrator at each phase transition and milestone completion.
|
> Updated by the orchestrator at each phase transition and milestone completion.
|
||||||
|
|
||||||
## Mission
|
## Mission
|
||||||
|
|
||||||
**ID:** harness-20260321
|
**ID:** cli-unification-20260404
|
||||||
**Statement:** Transform Mosaic Stack from a functional demo into a real multi-provider, task-routing AI harness. Persist all conversations, integrate frontier LLM providers (Anthropic, OpenAI, OpenRouter, Z.ai, Ollama), build granular task-aware agent routing, harden agent sessions, replace cron with BullMQ, and design the channel protocol for future Matrix/remote integration.
|
**Statement:** Transform the Mosaic CLI from a partially-duplicated, manually-assembled experience into a single cohesive entry point that installs, configures, and controls the entire Mosaic system. Every Mosaic package gets first-class CLI surface. The first-run experience works end-to-end with no manual stitching. Gateway token recovery is possible without the web UI. Opt-in telemetry uses the published telemetry clients.
|
||||||
**Phase:** Complete
|
**Phase:** Planning
|
||||||
**Current Milestone:** All milestones done
|
**Current Milestone:** —
|
||||||
**Progress:** 7 / 7 milestones
|
**Progress:** 1 / 8 milestones
|
||||||
**Status:** complete
|
**Status:** active
|
||||||
**Last Updated:** 2026-03-22 UTC
|
**Last Updated:** 2026-04-04
|
||||||
|
|
||||||
## Success Criteria
|
## Success Criteria
|
||||||
|
|
||||||
- [x] AC-1: Send messages in TUI → restart TUI → resume conversation → agent has full history and context
|
- [ ] AC-1: Fresh machine `bash <(curl …install.sh)` → single command lands on a working authenticated gateway with a usable admin token; no secondary manual wizards required
|
||||||
- [x] AC-2: Route a coding task to Claude Opus 4.6, a simple question to Haiku, a summarization to GLM-5 — all via granular routing rules
|
- [ ] AC-2: `mosaic --help` lists every sub-package as a top-level command and is alphabetized for readability
|
||||||
- [x] AC-3: Two users exist, User A's memory searches never return User B's data
|
- [ ] AC-3: `mosaic auth`, `mosaic brain`, `mosaic forge`, `mosaic log`, `mosaic macp`, `mosaic memory`, `mosaic queue`, `mosaic storage`, `mosaic telemetry` each expose at least one working subcommand that exercises the underlying package
|
||||||
- [x] AC-4: `/model claude-sonnet-4-6` in TUI switches the active model for subsequent messages
|
- [ ] AC-4: Gateway admin token can be rotated or recovered from the CLI alone — operator is never stranded because the web UI is inaccessible
|
||||||
- [x] AC-5: `/agent coding-agent` in TUI switches to a different agent with different system prompt and tools
|
- [ ] AC-5: `mosaic telemetry` uses the published `@mosaicstack/telemetry-client-js` (from the Gitea npm registry); local OTEL stays for wide-event logging / post-mortems; remote upload is opt-in and disabled by default
|
||||||
- [x] AC-6: BullMQ jobs execute on schedule, failures retry with backoff, admin can inspect via `/api/admin/jobs`
|
- [ ] AC-6: Install → wizard → gateway install → TUI verification flow is a single cohesive path with clear state transitions and no dead ends
|
||||||
- [x] AC-7: Channel protocol document exists with Matrix integration points defined, reviewed, and approved
|
- [ ] AC-7: `@mosaicstack/mosaic` is the sole `mosaic` binary owner; `@mosaicstack/cli` is gone from the repo and all docs
|
||||||
- [x] AC-8: Embeddings run on Ollama local models (no external API dependency for vector operations)
|
- [ ] AC-8: All milestones ship as merged PRs with green CI, closed issues, and updated release notes
|
||||||
- [x] AC-9: All five providers (Anthropic, OpenAI, OpenRouter, Z.ai, Ollama) connect, list models, and complete chat requests
|
|
||||||
- [x] AC-10: Routing transparency — TUI displays which model was selected and the routing reason for each response
|
|
||||||
|
|
||||||
## Milestones
|
## Milestones
|
||||||
|
|
||||||
| # | ID | Name | Status | Branch | Issue | Started | Completed |
|
| # | ID | Name | Status | Branch | Issue | Started | Completed |
|
||||||
| --- | ------ | ---------------------------------- | ------ | ------ | --------- | ---------- | ---------- |
|
| --- | ------ | ------------------------------------------------------------------------ | ----------- | ---------------------------------- | ----- | ---------- | ---------- |
|
||||||
| 1 | ms-166 | Conversation Persistence & Context | done | — | #224–#231 | 2026-03-21 | 2026-03-21 |
|
| 1 | cu-m01 | Kill legacy @mosaicstack/cli package | done | chore/remove-cli-package-duplicate | #398 | 2026-04-04 | 2026-04-04 |
|
||||||
| 2 | ms-167 | Security & Isolation | done | — | #232–#239 | 2026-03-21 | 2026-03-21 |
|
| 2 | cu-m02 | Archive stale mission state + scaffold new mission | in-progress | docs/mission-cli-unification | — | 2026-04-04 | — |
|
||||||
| 3 | ms-168 | Provider Integration | done | — | #240–#251 | 2026-03-21 | 2026-03-22 |
|
| 3 | cu-m03 | Fix gateway bootstrap token recovery (server + CLI paths) | not-started | — | — | — | — |
|
||||||
| 4 | ms-169 | Agent Routing Engine | done | — | #252–#264 | 2026-03-22 | 2026-03-22 |
|
| 4 | cu-m04 | Alphabetize + group `mosaic --help` output | not-started | — | — | — | — |
|
||||||
| 5 | ms-170 | Agent Session Hardening | done | — | #265–#272 | 2026-03-22 | 2026-03-22 |
|
| 5 | cu-m05 | Sub-package CLI surface (auth/brain/forge/log/macp/memory/queue/storage) | not-started | — | — | — | — |
|
||||||
| 6 | ms-171 | Job Queue Foundation | done | — | #273–#280 | 2026-03-22 | 2026-03-22 |
|
| 6 | cu-m06 | `mosaic telemetry` — local OTEL + opt-in remote upload | not-started | — | — | — | — |
|
||||||
| 7 | ms-172 | Channel Protocol Design | done | — | #281–#288 | 2026-03-22 | 2026-03-22 |
|
| 7 | cu-m07 | Unified first-run UX (install.sh → wizard → gateway → TUI) | not-started | — | — | — | — |
|
||||||
|
| 8 | cu-m08 | Docs refresh + release tag | not-started | — | — | — | — |
|
||||||
|
|
||||||
## Deployment
|
## Deployment
|
||||||
|
|
||||||
| Target | URL | Method |
|
| Target | URL | Method |
|
||||||
| -------------------- | --------- | -------------------------- |
|
| -------------------- | --------- | ----------------------------------------------- |
|
||||||
| Docker Compose (dev) | localhost | docker compose up |
|
| Local tier (default) | localhost | `mosaic gateway install` — pglite + local queue |
|
||||||
| Production | TBD | Docker Swarm via Portainer |
|
| Team tier | any host | `mosaic gateway install` — PG + Valkey |
|
||||||
|
| Docker Compose (dev) | localhost | `docker compose up` for PG/Valkey/OTEL/Jaeger |
|
||||||
|
|
||||||
## Coordination
|
## Coordination
|
||||||
|
|
||||||
- **Primary Agent:** claude-opus-4-6
|
- **Primary Agent:** claude-opus-4-6[1m]
|
||||||
- **Sibling Agents:** sonnet (workers), haiku (verification)
|
- **Sibling Agents:** sonnet (standard implementation), haiku (status/explore/verify), codex (coding-heavy tasks)
|
||||||
- **Shared Contracts:** docs/PRD-Harness_Foundation.md, docs/TASKS.md
|
- **Shared Contracts:** `docs/PRD.md` (existing v0.1.0 PRD — still the long-term target), this manifest, `docs/TASKS.md`, `docs/scratchpads/cli-unification-20260404.md`
|
||||||
|
|
||||||
## Token Budget
|
## Token Budget
|
||||||
|
|
||||||
| Metric | Value |
|
| Metric | Value |
|
||||||
| ------ | ------ |
|
| ------ | ------ |
|
||||||
| Budget | — |
|
| Budget | TBD |
|
||||||
| Used | ~2.5M |
|
| Used | ~80K |
|
||||||
| Mode | normal |
|
| Mode | normal |
|
||||||
|
|
||||||
## Session History
|
## Session History
|
||||||
|
|
||||||
| Session | Runtime | Started | Duration | Ended Reason | Last Task |
|
| Session | Runtime | Started | Duration | Ended Reason | Last Task |
|
||||||
| ------- | --------------- | ---------- | -------- | ------------ | ----------------- |
|
| ------- | --------------- | ---------- | --------- | ------------ | ---------------------------------------------------- |
|
||||||
| 1 | claude-opus-4-6 | 2026-03-21 | ~6h | complete | M7-008 — all done |
|
| 1 | claude-opus-4-6 | 2026-04-04 | in-flight | — | cu-m01 merged (PR #398); cu-m02 scaffold in progress |
|
||||||
|
|
||||||
## Scratchpad
|
## Scratchpad
|
||||||
|
|
||||||
Path: `docs/scratchpads/harness-20260321.md`
|
Path: `docs/scratchpads/cli-unification-20260404.md`
|
||||||
|
|||||||
110
docs/TASKS.md
110
docs/TASKS.md
@@ -1,30 +1,88 @@
|
|||||||
# Tasks — Storage Abstraction Retrofit
|
# Tasks — CLI Unification & E2E First-Run
|
||||||
|
|
||||||
> Single-writer: orchestrator only. Workers read but never modify.
|
> Single-writer: orchestrator only. Workers read but never modify.
|
||||||
>
|
>
|
||||||
> **Mission:** Decouple gateway from hardcoded Postgres/Valkey backends. Introduce interface-driven middleware so the gateway is backend-agnostic. Default to local tier (SQLite + JSON) for zero-dependency installs.
|
> **Mission:** cli-unification-20260404
|
||||||
>
|
> **Schema:** `| id | status | description | issue | agent | branch | depends_on | estimate | notes |`
|
||||||
> **`agent` column values:** `codex` | `sonnet` | `haiku` | `glm-5` | `opus` | `—` (auto/default)
|
> **Status values:** `not-started` | `in-progress` | `done` | `blocked` | `failed` | `needs-qa`
|
||||||
|
> **Agent values:** `codex` | `sonnet` | `haiku` | `opus` | `glm-5` | `—` (auto)
|
||||||
|
|
||||||
| id | status | agent | description | tokens |
|
## Milestone 1 — Kill legacy @mosaicstack/cli (done)
|
||||||
| --------- | ----------- | ------ | ---------------------------------------------------------------- | ------ |
|
|
||||||
| SA-P1-001 | done | sonnet | Define QueueAdapter interface in packages/queue/src/types.ts | 3K |
|
| id | status | description | issue | agent | branch | depends_on | estimate | notes |
|
||||||
| SA-P1-002 | done | sonnet | Define StorageAdapter interface in packages/storage/src/types.ts | 3K |
|
| -------- | ------ | ----------------------------------------------------------------- | ----- | ----- | ---------------------------------- | ---------- | -------- | --------------------------- |
|
||||||
| SA-P1-003 | done | sonnet | Define MemoryAdapter interface in packages/memory/src/types.ts | 3K |
|
| CU-01-01 | done | Delete packages/cli directory; update workspace + docs references | #398 | opus | chore/remove-cli-package-duplicate | — | 5K | Merged c39433c3. 6685 LOC−. |
|
||||||
| SA-P1-004 | done | sonnet | Create adapter factory pattern + config types | 3K |
|
|
||||||
| SA-P2-001 | done | sonnet | Refactor @mosaicstack/queue: wrap ioredis as BullMQ adapter | 3K |
|
## Milestone 2 — Archive stale mission + scaffold new mission (in-progress)
|
||||||
| SA-P2-002 | done | sonnet | Create @mosaicstack/storage: wrap Drizzle as Postgres adapter | 6K |
|
|
||||||
| SA-P2-003 | done | sonnet | Refactor @mosaicstack/memory: extract pgvector adapter | 4K |
|
| id | status | description | issue | agent | branch | depends_on | estimate | notes |
|
||||||
| SA-P2-004 | done | sonnet | Update gateway modules to use factories + DI tokens | 5K |
|
| -------- | ----------- | ------------------------------------------------------------------ | ----- | ----- | ---------------------------- | ---------- | -------- | --------------------------------- |
|
||||||
| SA-P2-005 | done | opus | Verify Phase 2: all tests pass, typecheck clean | — |
|
| CU-02-01 | in-progress | Move stale MISSION-MANIFEST / TASKS / PRD-Harness to docs/archive/ | — | opus | docs/mission-cli-unification | CU-01-01 | 3K | Harness + storage missions done. |
|
||||||
| SA-P3-001 | done | sonnet | Implement local queue adapter: JSON file persistence | 5K |
|
| CU-02-02 | in-progress | Scaffold new MISSION-MANIFEST.md, TASKS.md, scratchpad | — | opus | docs/mission-cli-unification | CU-02-01 | 5K | This file + manifest + scratchpad |
|
||||||
| SA-P3-002 | done | sonnet | Implement SQLite storage adapter with better-sqlite3 | 8K |
|
| CU-02-03 | not-started | PR review, merge, branch cleanup | — | opus | docs/mission-cli-unification | CU-02-02 | 2K | Must be green CI + merged |
|
||||||
| SA-P3-003 | done | sonnet | Implement keyword memory adapter — no vector dependency | 4K |
|
|
||||||
| SA-P3-004 | done | opus | Verify Phase 3: 42 new tests, 347 total passing | — |
|
## Milestone 3 — Gateway bootstrap token recovery
|
||||||
| SA-P4-001 | done | sonnet | MosaicConfig schema + loader with tier auto-detection | 6K |
|
|
||||||
| SA-P4-002 | done | sonnet | CLI: mosaic gateway init — interactive wizard | 4K |
|
| id | status | description | issue | agent | branch | depends_on | estimate | notes |
|
||||||
| SA-P4-003 | done | sonnet | CLI: mosaic gateway start/stop/status lifecycle | 5K |
|
| -------- | ----------- | ---------------------------------------------------------------------------------------------- | ----- | ------ | ------ | ---------- | -------- | ----- |
|
||||||
| SA-P4-004 | done | opus | Verify Phase 4: 381 tests passing, 40/40 tasks clean | — |
|
| CU-03-01 | not-started | Design recovery flow (filesystem-signed nonce vs authenticated cookie vs rescue CLI flag) | — | opus | — | CU-02-03 | 8K | Spike |
|
||||||
| SA-P5-001 | not-started | codex | Migration tooling: mosaic storage export/import | — |
|
| CU-03-02 | not-started | Server: add recovery/rotate endpoint on apps/gateway/src/admin (gated by design from CU-03-01) | — | sonnet | — | CU-03-01 | 12K | |
|
||||||
| SA-P5-002 | not-started | codex | Docker Compose profiles: local vs team | — |
|
| CU-03-03 | not-started | CLI: `mosaic gateway login` — interactive BetterAuth sign-in, persist session | — | sonnet | — | CU-03-02 | 10K | |
|
||||||
| SA-P5-003 | not-started | codex | Final verification + docs: README, architecture diagram | — |
|
| CU-03-04 | not-started | CLI: `mosaic gateway config rotate-token` — mint new admin token via authenticated API | — | sonnet | — | CU-03-03 | 8K | |
|
||||||
|
| CU-03-05 | not-started | CLI: `mosaic gateway config recover-token` — execute the recovery flow from CU-03-01 | — | sonnet | — | CU-03-03 | 10K | |
|
||||||
|
| CU-03-06 | not-started | Install UX: fix the "user exists, no token" dead-end in runInstall bootstrapFirstUser path | — | sonnet | — | CU-03-05 | 8K | |
|
||||||
|
| CU-03-07 | not-started | Tests: integration tests for each recovery path (happy + error) | — | sonnet | — | CU-03-06 | 10K | |
|
||||||
|
| CU-03-08 | not-started | Code review + remediation | — | haiku | — | CU-03-07 | 4K | |
|
||||||
|
|
||||||
|
## Milestone 4 — `mosaic --help` alphabetize + grouping
|
||||||
|
|
||||||
|
| id | status | description | issue | agent | branch | depends_on | estimate | notes |
|
||||||
|
| -------- | ----------- | ----------------------------------------------------------------------------------- | ----- | ------ | ------ | ---------- | -------- | ----- |
|
||||||
|
| CU-04-01 | not-started | Enable `configureHelp({ sortSubcommands: true })` on root program and each subgroup | — | sonnet | — | CU-02-03 | 3K | |
|
||||||
|
| CU-04-02 | not-started | Group commands into sections (Runtime, Gateway, Framework, Platform) in help output | — | sonnet | — | CU-04-01 | 5K | |
|
||||||
|
| CU-04-03 | not-started | Verify help snapshots render readably; update any docs with stale output | — | haiku | — | CU-04-02 | 3K | |
|
||||||
|
|
||||||
|
## Milestone 5 — Sub-package CLI surface
|
||||||
|
|
||||||
|
> Pattern: each sub-package exports `register<Name>Command(program: Command)` co-located with the library code (proven by `@mosaicstack/quality-rails`). Wire into `packages/mosaic/src/cli.ts`.
|
||||||
|
|
||||||
|
| id | status | description | issue | agent | branch | depends_on | estimate | notes |
|
||||||
|
| -------- | ----------- | --------------------------------------------------------------------------------------------------------- | ----- | ------ | ------ | ---------- | -------- | ------------------- |
|
||||||
|
| CU-05-01 | not-started | `mosaic forge` — subcommands: `run`, `status`, `resume`, `personas list` | — | sonnet | — | CU-02-03 | 18K | User priority |
|
||||||
|
| CU-05-02 | not-started | `mosaic storage` — subcommands: `status`, `tier show`, `tier switch`, `export`, `import`, `migrate` | — | sonnet | — | CU-02-03 | 15K | |
|
||||||
|
| CU-05-03 | not-started | `mosaic queue` — subcommands: `list`, `stats`, `pause/resume`, `jobs tail`, `drain` | — | sonnet | — | CU-02-03 | 12K | |
|
||||||
|
| CU-05-04 | not-started | `mosaic memory` — subcommands: `search`, `stats`, `insights list`, `preferences list` | — | sonnet | — | CU-02-03 | 12K | |
|
||||||
|
| CU-05-05 | not-started | `mosaic brain` — subcommands: `projects list/create`, `missions list`, `tasks list`, `conversations list` | — | sonnet | — | CU-02-03 | 15K | |
|
||||||
|
| CU-05-06 | not-started | `mosaic auth` — subcommands: `users list/create/delete`, `sso list`, `sso test`, `sessions list` | — | sonnet | — | CU-03-03 | 15K | needs gateway login |
|
||||||
|
| CU-05-07 | not-started | `mosaic log` — subcommands: `tail`, `search`, `export`, `level <level>` | — | sonnet | — | CU-02-03 | 10K | |
|
||||||
|
| CU-05-08 | not-started | `mosaic macp` — subcommands: `tasks list`, `submit`, `gate`, `events tail` | — | sonnet | — | CU-02-03 | 12K | |
|
||||||
|
| CU-05-09 | not-started | Wire all eight `register<Name>Command` calls into packages/mosaic/src/cli.ts | — | haiku | — | CU-05-01…8 | 3K | |
|
||||||
|
| CU-05-10 | not-started | Integration test: `mosaic <cmd> --help` exits 0 for every new command | — | haiku | — | CU-05-09 | 5K | |
|
||||||
|
|
||||||
|
## Milestone 6 — `mosaic telemetry`
|
||||||
|
|
||||||
|
| id | status | description | issue | agent | branch | depends_on | estimate | notes |
|
||||||
|
| -------- | ----------- | ------------------------------------------------------------------------------------------------- | ----- | ------ | ------ | ---------- | -------- | ---------------------------------------------- |
|
||||||
|
| CU-06-01 | not-started | Add `@mosaicstack/telemetry-client-js` as dependency of `@mosaicstack/mosaic` from Gitea registry | — | sonnet | — | CU-02-03 | 3K | |
|
||||||
|
| CU-06-02 | not-started | `mosaic telemetry local` — status, tail, Jaeger link (wraps existing apps/gateway/src/tracing.ts) | — | sonnet | — | CU-06-01 | 8K | |
|
||||||
|
| CU-06-03 | not-started | `mosaic telemetry` — status, opt-in, opt-out, test, upload (uses telemetry-client-js) | — | sonnet | — | CU-06-01 | 12K | Dry-run mode when server endpoint not yet live |
|
||||||
|
| CU-06-04 | not-started | Persistent consent state in mosaic config; disabled by default | — | sonnet | — | CU-06-03 | 5K | |
|
||||||
|
| CU-06-05 | not-started | Tests + code review | — | haiku | — | CU-06-04 | 5K | |
|
||||||
|
|
||||||
|
## Milestone 7 — Unified first-run UX
|
||||||
|
|
||||||
|
| id | status | description | issue | agent | branch | depends_on | estimate | notes |
|
||||||
|
| -------- | ----------- | ---------------------------------------------------------------------------------------------- | ----- | ------ | ------ | ---------- | -------- | ----- |
|
||||||
|
| CU-07-01 | not-started | tools/install.sh: after npm install, hand off to `mosaic wizard` then `mosaic gateway install` | — | sonnet | — | CU-03-06 | 10K | |
|
||||||
|
| CU-07-02 | not-started | `mosaic wizard` and `mosaic gateway install` coordination: shared state, no duplicate prompts | — | sonnet | — | CU-07-01 | 12K | |
|
||||||
|
| CU-07-03 | not-started | Post-install verification step: "gateway healthy, tui connects, admin token on file" | — | sonnet | — | CU-07-02 | 8K | |
|
||||||
|
| CU-07-04 | not-started | End-to-end test on a clean container from scratch | — | haiku | — | CU-07-03 | 8K | |
|
||||||
|
|
||||||
|
## Milestone 8 — Docs + release
|
||||||
|
|
||||||
|
| id | status | description | issue | agent | branch | depends_on | estimate | notes |
|
||||||
|
| -------- | ----------- | ---------------------------------------------------------------------- | ----- | ------ | ------ | ---------- | -------- | ----- |
|
||||||
|
| CU-08-01 | not-started | Update README.md with new command tree, install flow, and feature list | — | sonnet | — | CU-07-04 | 8K | |
|
||||||
|
| CU-08-02 | not-started | Update docs/guides/user-guide.md with all new sub-package commands | — | sonnet | — | CU-08-01 | 10K | |
|
||||||
|
| CU-08-03 | not-started | Version bump `@mosaicstack/mosaic`, publish to Gitea registry | — | opus | — | CU-08-02 | 3K | |
|
||||||
|
| CU-08-04 | not-started | Release notes, tag `v0.1.0-rc.N`, publish release on Gitea | — | opus | — | CU-08-03 | 3K | |
|
||||||
|
|||||||
70
docs/archive/missions/harness-20260321/MISSION-MANIFEST.md
Normal file
70
docs/archive/missions/harness-20260321/MISSION-MANIFEST.md
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
# Mission Manifest — Harness Foundation
|
||||||
|
|
||||||
|
> Persistent document tracking full mission scope, status, and session history.
|
||||||
|
> Updated by the orchestrator at each phase transition and milestone completion.
|
||||||
|
|
||||||
|
## Mission
|
||||||
|
|
||||||
|
**ID:** harness-20260321
|
||||||
|
**Statement:** Transform Mosaic Stack from a functional demo into a real multi-provider, task-routing AI harness. Persist all conversations, integrate frontier LLM providers (Anthropic, OpenAI, OpenRouter, Z.ai, Ollama), build granular task-aware agent routing, harden agent sessions, replace cron with BullMQ, and design the channel protocol for future Matrix/remote integration.
|
||||||
|
**Phase:** Complete
|
||||||
|
**Current Milestone:** All milestones done
|
||||||
|
**Progress:** 7 / 7 milestones
|
||||||
|
**Status:** complete
|
||||||
|
**Last Updated:** 2026-03-22 UTC
|
||||||
|
|
||||||
|
## Success Criteria
|
||||||
|
|
||||||
|
- [x] AC-1: Send messages in TUI → restart TUI → resume conversation → agent has full history and context
|
||||||
|
- [x] AC-2: Route a coding task to Claude Opus 4.6, a simple question to Haiku, a summarization to GLM-5 — all via granular routing rules
|
||||||
|
- [x] AC-3: Two users exist, User A's memory searches never return User B's data
|
||||||
|
- [x] AC-4: `/model claude-sonnet-4-6` in TUI switches the active model for subsequent messages
|
||||||
|
- [x] AC-5: `/agent coding-agent` in TUI switches to a different agent with different system prompt and tools
|
||||||
|
- [x] AC-6: BullMQ jobs execute on schedule, failures retry with backoff, admin can inspect via `/api/admin/jobs`
|
||||||
|
- [x] AC-7: Channel protocol document exists with Matrix integration points defined, reviewed, and approved
|
||||||
|
- [x] AC-8: Embeddings run on Ollama local models (no external API dependency for vector operations)
|
||||||
|
- [x] AC-9: All five providers (Anthropic, OpenAI, OpenRouter, Z.ai, Ollama) connect, list models, and complete chat requests
|
||||||
|
- [x] AC-10: Routing transparency — TUI displays which model was selected and the routing reason for each response
|
||||||
|
|
||||||
|
## Milestones
|
||||||
|
|
||||||
|
| # | ID | Name | Status | Branch | Issue | Started | Completed |
|
||||||
|
| --- | ------ | ---------------------------------- | ------ | ------ | --------- | ---------- | ---------- |
|
||||||
|
| 1 | ms-166 | Conversation Persistence & Context | done | — | #224–#231 | 2026-03-21 | 2026-03-21 |
|
||||||
|
| 2 | ms-167 | Security & Isolation | done | — | #232–#239 | 2026-03-21 | 2026-03-21 |
|
||||||
|
| 3 | ms-168 | Provider Integration | done | — | #240–#251 | 2026-03-21 | 2026-03-22 |
|
||||||
|
| 4 | ms-169 | Agent Routing Engine | done | — | #252–#264 | 2026-03-22 | 2026-03-22 |
|
||||||
|
| 5 | ms-170 | Agent Session Hardening | done | — | #265–#272 | 2026-03-22 | 2026-03-22 |
|
||||||
|
| 6 | ms-171 | Job Queue Foundation | done | — | #273–#280 | 2026-03-22 | 2026-03-22 |
|
||||||
|
| 7 | ms-172 | Channel Protocol Design | done | — | #281–#288 | 2026-03-22 | 2026-03-22 |
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
| Target | URL | Method |
|
||||||
|
| -------------------- | --------- | -------------------------- |
|
||||||
|
| Docker Compose (dev) | localhost | docker compose up |
|
||||||
|
| Production | TBD | Docker Swarm via Portainer |
|
||||||
|
|
||||||
|
## Coordination
|
||||||
|
|
||||||
|
- **Primary Agent:** claude-opus-4-6
|
||||||
|
- **Sibling Agents:** sonnet (workers), haiku (verification)
|
||||||
|
- **Shared Contracts:** docs/PRD-Harness_Foundation.md, docs/TASKS.md
|
||||||
|
|
||||||
|
## Token Budget
|
||||||
|
|
||||||
|
| Metric | Value |
|
||||||
|
| ------ | ------ |
|
||||||
|
| Budget | — |
|
||||||
|
| Used | ~2.5M |
|
||||||
|
| Mode | normal |
|
||||||
|
|
||||||
|
## Session History
|
||||||
|
|
||||||
|
| Session | Runtime | Started | Duration | Ended Reason | Last Task |
|
||||||
|
| ------- | --------------- | ---------- | -------- | ------------ | ----------------- |
|
||||||
|
| 1 | claude-opus-4-6 | 2026-03-21 | ~6h | complete | M7-008 — all done |
|
||||||
|
|
||||||
|
## Scratchpad
|
||||||
|
|
||||||
|
Path: `docs/scratchpads/harness-20260321.md`
|
||||||
30
docs/archive/missions/storage-abstraction/TASKS.md
Normal file
30
docs/archive/missions/storage-abstraction/TASKS.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Tasks — Storage Abstraction Retrofit
|
||||||
|
|
||||||
|
> Single-writer: orchestrator only. Workers read but never modify.
|
||||||
|
>
|
||||||
|
> **Mission:** Decouple gateway from hardcoded Postgres/Valkey backends. Introduce interface-driven middleware so the gateway is backend-agnostic. Default to local tier (SQLite + JSON) for zero-dependency installs.
|
||||||
|
>
|
||||||
|
> **`agent` column values:** `codex` | `sonnet` | `haiku` | `glm-5` | `opus` | `—` (auto/default)
|
||||||
|
|
||||||
|
| id | status | agent | description | tokens |
|
||||||
|
| --------- | ----------- | ------ | ---------------------------------------------------------------- | ------ |
|
||||||
|
| SA-P1-001 | done | sonnet | Define QueueAdapter interface in packages/queue/src/types.ts | 3K |
|
||||||
|
| SA-P1-002 | done | sonnet | Define StorageAdapter interface in packages/storage/src/types.ts | 3K |
|
||||||
|
| SA-P1-003 | done | sonnet | Define MemoryAdapter interface in packages/memory/src/types.ts | 3K |
|
||||||
|
| SA-P1-004 | done | sonnet | Create adapter factory pattern + config types | 3K |
|
||||||
|
| SA-P2-001 | done | sonnet | Refactor @mosaicstack/queue: wrap ioredis as BullMQ adapter | 3K |
|
||||||
|
| SA-P2-002 | done | sonnet | Create @mosaicstack/storage: wrap Drizzle as Postgres adapter | 6K |
|
||||||
|
| SA-P2-003 | done | sonnet | Refactor @mosaicstack/memory: extract pgvector adapter | 4K |
|
||||||
|
| SA-P2-004 | done | sonnet | Update gateway modules to use factories + DI tokens | 5K |
|
||||||
|
| SA-P2-005 | done | opus | Verify Phase 2: all tests pass, typecheck clean | — |
|
||||||
|
| SA-P3-001 | done | sonnet | Implement local queue adapter: JSON file persistence | 5K |
|
||||||
|
| SA-P3-002 | done | sonnet | Implement SQLite storage adapter with better-sqlite3 | 8K |
|
||||||
|
| SA-P3-003 | done | sonnet | Implement keyword memory adapter — no vector dependency | 4K |
|
||||||
|
| SA-P3-004 | done | opus | Verify Phase 3: 42 new tests, 347 total passing | — |
|
||||||
|
| SA-P4-001 | done | sonnet | MosaicConfig schema + loader with tier auto-detection | 6K |
|
||||||
|
| SA-P4-002 | done | sonnet | CLI: mosaic gateway init — interactive wizard | 4K |
|
||||||
|
| SA-P4-003 | done | sonnet | CLI: mosaic gateway start/stop/status lifecycle | 5K |
|
||||||
|
| SA-P4-004 | done | opus | Verify Phase 4: 381 tests passing, 40/40 tasks clean | — |
|
||||||
|
| SA-P5-001 | not-started | codex | Migration tooling: mosaic storage export/import | — |
|
||||||
|
| SA-P5-002 | not-started | codex | Docker Compose profiles: local vs team | — |
|
||||||
|
| SA-P5-003 | not-started | codex | Final verification + docs: README, architecture diagram | — |
|
||||||
96
docs/scratchpads/cli-unification-20260404.md
Normal file
96
docs/scratchpads/cli-unification-20260404.md
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
# Mission Scratchpad — CLI Unification & E2E First-Run
|
||||||
|
|
||||||
|
> Append-only log. NEVER delete entries. NEVER overwrite sections.
|
||||||
|
> This is the orchestrator's working memory across sessions.
|
||||||
|
|
||||||
|
**Mission ID:** cli-unification-20260404
|
||||||
|
**Started:** 2026-04-04
|
||||||
|
**Related PRDs:** `docs/PRD.md` (v0.1.0 long-term target)
|
||||||
|
|
||||||
|
## Original Mission Prompt
|
||||||
|
|
||||||
|
Original user framing (2026-04-04):
|
||||||
|
|
||||||
|
> We are off the reservation right now. Working on getting the system to work via cli first, then working on the webUI. The missions are likely all wrong. The PRDs might have valid info.
|
||||||
|
>
|
||||||
|
> E2E install to functional, with Mosaic Forge working. `mosaic gateway` config is broken — no token is created. Unable to configure. Installation doesn't really configure, it just installs and launches the gateway. Multiple `mosaic` commands are missing that should be included. Unified installer experience is not ready. UX is bad.
|
||||||
|
>
|
||||||
|
> The various mosaic packages will need to be available within the mosaic cli: `mosaic auth`, `mosaic brain`, `mosaic forge`, `mosaic log`, `mosaic macp`, `mosaic memory`, `mosaic queue`, `mosaic storage`.
|
||||||
|
>
|
||||||
|
> The list of commands in `mosaic --help` also need to be alphabetized for readability.
|
||||||
|
>
|
||||||
|
> `mosaic telemetry` should also exist. Local OTEL for wide-event logging / post-mortems. Remote upload opt-in via `@mosaicstack/telemetry-client-js` (https://git.mosaicstack.dev/mosaicstack/telemetry-client-js) — the telemetry server will be part of the main mosaicstack.dev website. Python counterpart at https://git.mosaicstack.dev/mosaicstack/telemetry-client-py.
|
||||||
|
|
||||||
|
## Planning Decisions
|
||||||
|
|
||||||
|
### 2026-04-04 — State discovery + prep PR
|
||||||
|
|
||||||
|
**Critical finding:** Two CLI packages both owned `bin.mosaic` — `@mosaicstack/mosaic` (0.0.21) and `@mosaicstack/cli` (0.0.17). Their `src/cli.ts` files were near-verbatim duplicates (424 vs 422 lines) and their `src/commands/` directories overlapped, with some files silently diverging (notably `gateway/install.ts`, the version responsible for the broken install UX). Whichever package was linked last won the `mosaic` symlink.
|
||||||
|
|
||||||
|
**Decision:** `@mosaicstack/cli` dies. `@mosaicstack/mosaic` is the single CLI + TUI package. This was confirmed with user ("The @mosaicstack/cli package is no longer a package. Its features were moved to @mosaicstack/mosaic instead."). Prep PR #398 executed the removal.
|
||||||
|
|
||||||
|
**Decision:** CLI registration pattern = `register<Name>Command(parent: Command)` exported by each sub-package, co-located with the library code. Proven by `@mosaicstack/quality-rails` → `registerQualityRails(program)`. Avoids cross-package commander version mismatches.
|
||||||
|
|
||||||
|
**Decision:** Stale mission state (harness-20260321 manifest, storage-abstraction TASKS.md, PRD-Harness_Foundation.md) gets archived under `docs/archive/missions/`. Scratchpads for completed sub-missions are left in `docs/scratchpads/` as historical record — they're append-only by design and valuable as breadcrumbs.
|
||||||
|
|
||||||
|
### 2026-04-04 — Gateway bootstrap token bug root cause
|
||||||
|
|
||||||
|
`apps/gateway/src/admin/bootstrap.controller.ts`:
|
||||||
|
|
||||||
|
- `GET /api/bootstrap/status` returns `needsSetup: true` **only** when `users` table count is zero
|
||||||
|
- `POST /api/bootstrap/setup` throws `ForbiddenException` if any user exists
|
||||||
|
|
||||||
|
`packages/mosaic/src/commands/gateway/install.ts` — `runInstall()` "explicit reinstall" branch (lines ~87–98):
|
||||||
|
|
||||||
|
1. Clears `meta.adminToken` from meta.json (line 175 — `preserveToken = false` when `regeneratedConfig = true`)
|
||||||
|
2. Calls `bootstrapFirstUser()`
|
||||||
|
3. Status endpoint returns `needsSetup: false` because users row still exists
|
||||||
|
4. `bootstrapFirstUser` prints _"Admin user already exists — skipping setup. (No admin token on file — sign in via the web UI to manage tokens.)"_ and returns
|
||||||
|
5. Install "succeeds" with NO token, NO CLI path to generate one, and chicken-and-egg on `/api/admin/tokens` which requires auth
|
||||||
|
|
||||||
|
**Recovery design options (to decide in CU-03-01):**
|
||||||
|
|
||||||
|
- Filesystem-signed nonce file written by the installer; recovery endpoint checks it
|
||||||
|
- Accept a valid BetterAuth admin session cookie → mint new admin token via authenticated API call (leans on existing auth; `mosaic gateway login` becomes the recovery entry point)
|
||||||
|
- Gateway daemon accepts `--rescue` flag that mints a one-shot recovery token, prints it, then exits
|
||||||
|
|
||||||
|
Current lean: option 2 (BetterAuth cookie) because it reuses existing auth and gives us `mosaic gateway login` as a useful command regardless. But the design spike in CU-03-01 should evaluate all three against: security, complexity, headless-environment friendliness, and disaster-recovery scenarios.
|
||||||
|
|
||||||
|
### 2026-04-04 — Telemetry architecture
|
||||||
|
|
||||||
|
- `@mosaicstack/telemetry-client-js` + `@mosaicstack/telemetry-client-py` are separate repos on Gitea — **not** currently consumed anywhere in this monorepo (verified via grep)
|
||||||
|
- Telemetry server will be combined with the main mosaicstack.dev website (not built yet)
|
||||||
|
- Local OTEL stays — `apps/gateway/src/tracing.ts` already wires it up for wide-event logging and post-mortem traces
|
||||||
|
- `mosaic telemetry` is a thin wrapper that:
|
||||||
|
- `mosaic telemetry local {status,tail,jaeger}` → local OTEL state, Jaeger links
|
||||||
|
- `mosaic telemetry {status,opt-in,opt-out,test,upload}` → remote upload path via telemetry-client-js
|
||||||
|
- Remote disabled by default; opt-in requires explicit consent
|
||||||
|
- `test`/`upload` ship with dry-run mode until the server endpoint is live
|
||||||
|
|
||||||
|
## Session Log
|
||||||
|
|
||||||
|
| Session | Date | Milestone | Tasks Done | Outcome |
|
||||||
|
| ------- | ---------- | ------------------------- | ------------------------------ | -------------------------------------------------------------------------------------------------- |
|
||||||
|
| 1 | 2026-04-04 | cu-m01 Kill legacy CLI | CU-01-01 | PR #398 merged to main as `c39433c3`. 48 files deleted, 6685 LOC removed. CI green (pipeline 702). |
|
||||||
|
| 1 | 2026-04-04 | cu-m02 Archive + scaffold | CU-02-01, CU-02-02 (this file) | In progress — this PR. |
|
||||||
|
|
||||||
|
## Corrections / Course Changes
|
||||||
|
|
||||||
|
_(append here as they happen)_
|
||||||
|
|
||||||
|
## Open Risks
|
||||||
|
|
||||||
|
- **Telemetry server not live:** CU-06-03 (`mosaic telemetry upload`) may need a dry-run stub until the server endpoint exists on mosaicstack.dev. Not blocking for this mission, but ships with reduced validation until then.
|
||||||
|
- **`mosaic auth` depends on gateway login:** CU-05-06 is gated by CU-03-03 (`mosaic gateway login`). Sequencing matters — do not start CU-05-06 until M3 is done or significantly underway.
|
||||||
|
- **pr-create.sh wrapper bug:** Discovered during M1 — `~/.config/mosaic/tools/git/pr-create.sh` line 158 uses `eval "$CMD"`, which shell-evaluates any backticks / `$(…)` / `${…}` in PR bodies. Workaround: strip backticks from PR bodies (use bold / italic / plain text instead), or use `tea pr create` directly. Captured in openbrain as gotcha. Should be fixed upstream in Mosaic tools repo at some point, but out of scope for this mission.
|
||||||
|
- **Mosaic coord / orchestrator session lock drift:** `.mosaic/orchestrator/session.lock` gets re-written every session launch and shows up as a dirty working tree on branch switch. Not blocking — just noise to ignore.
|
||||||
|
|
||||||
|
## Verification Evidence
|
||||||
|
|
||||||
|
### CU-01-01 (PR #398)
|
||||||
|
|
||||||
|
- Branch: `chore/remove-cli-package-duplicate`
|
||||||
|
- Commit: `7206b9411d96`
|
||||||
|
- Merge commit on main: `c39433c3`
|
||||||
|
- CI pipeline: #702 (`pull_request` event, all 6 steps green: postgres, install, typecheck, lint, format, test)
|
||||||
|
- Quality gates (pre-push): typecheck 38/38, lint 21/21, format clean, test 38/38
|
||||||
Reference in New Issue
Block a user