feat(api): GET /api/workspaces/:id/stats endpoint

This commit is contained in:
2026-03-01 15:35:02 -06:00
commit fe87122179
41 changed files with 8471 additions and 0 deletions

175
MEMORY.md Normal file
View File

@@ -0,0 +1,175 @@
# MEMORY.md - Long-Term Memory
## ⚠️ CRITICAL RULES (Read Every Session)
### Mosaic Framework — MANDATORY FOR ALL AGENT LAUNCHES
**BEFORE spawning ANY worker, you MUST:**
1. Read `~/.config/mosaic/guides/ORCHESTRATOR.md` in full
2. Read `~/.config/mosaic/guides/E2E-DELIVERY.md` in full
3. Declare mode: `Now initiating Orchestrator mode...`
**This is not optional. Skipping the framework = violation.**
### Model Hierarchy — FOLLOW THIS EXACTLY
| Tier | Model | Use For | Budget Impact |
|------|-------|---------|---------------|
| **Opus (me)** | claude-opus-4 | Orchestration ONLY. Major planning ONLY if massive. | HIGHEST — minimize my context burn |
| **Sonnet** | claude-sonnet-4 | Coding tasks, most planning tasks | Medium — 1 at a time max |
| **Haiku** | claude-haiku | Easy discovery, simple research, light tasks | Low |
| **Codex** | gpt-5.2-codex | Coding tasks (runs on OpenAI credits, NOT Claude) | Separate budget |
### NestJS DTO Import Rule — NEVER `import type` for DTOs in Controllers
`import type { Dto }` is erased at runtime → reflect-metadata records `Function` → ValidationPipe forbids ALL fields.
Always use value import: `import { SomeDto }` for any class used in @Body(), @Query(), @Param().
### Claude Subscription Quota — DO NOT BURN IT
- **Problem:** Spawning multiple parallel Claude workers burns through Jason's Claude subscription extremely fast.
- **This has happened MULTIPLE TIMES.** Recurring mistake. ZERO tolerance now.
- **Rules:**
1. **I (Opus) do NOT code.** I orchestrate. Period.
2. **Max 1 Claude (Sonnet) worker at a time.** Serial only.
3. **Max 6 Codex (ACP) workers at a time.** Prefer for all coding — uses OpenAI credits, not Claude.
4. **Codex via ACP:** `sessions_spawn` with `runtime:"acp"`, `agentId:"codex"`. No exec hacks.
4. **Use Haiku** for discovery/research tasks.
5. **Use Sonnet** for coding when Codex isn't suitable, and for planning.
6. **Track budget explicitly** — estimate before spawning, record after completing.
- **Last violated:** 2026-02-28 — spawned parallel Claude workers.
### Orchestration Framework
- **Follow `~/.config/mosaic` framework** for all orchestration
- Mosaic ORCHESTRATOR.md = per-session execution protocol
- Mosaic ORCHESTRATOR-PROTOCOL.md = mission lifecycle across sessions
- Max 2 parallel workers (but only 1 can be Claude/Sonnet)
- Orchestrator NEVER writes code — spawn workers for ALL code changes
- Orchestrator is sole writer of docs/TASKS.md
### Agent Launch Patterns
- **Codex via ACP (PREFERRED):** `sessions_spawn` with `runtime:"acp"`, `agentId:"codex"`, `mode:"run"` — auto-announces on completion
- **Claude Code (Sonnet):** `claude -p --model sonnet --dangerously-skip-permissions "prompt"` via PTY in project workdir
- **Codex exec (AVOID):** `setsid sh -c 'cat prompt | codex exec ...'` — gets SIGTERM'd on session cleanup
- **Background mode:** Use `background:true` + `pty:true` via exec tool
- **Notify on completion:** Append `openclaw system event --text "Done: summary" --mode now` to prompts
- **GLM-5 subagents**: model alias `zai/glm-5` does NOT apply to subagents — they run as Opus! Budget risk.
---
## Critical Lesson: Follow the Mosaic Framework COMPLETELY
On 2026-02-28, Jason called me out for skipping the E2E delivery requirements from the Mosaic framework. I dispatched workers and marked tasks done without:
- Running post-coding reviews BEFORE marking done
- Waiting for CI green
- Closing issues
- Creating scratchpads
- Following the full ORCHESTRATOR.md and E2E-DELIVERY.md protocols
**Next session MUST:** Read `~/.config/mosaic/guides/ORCHESTRATOR.md` and `~/.config/mosaic/guides/E2E-DELIVERY.md` BEFORE dispatching any workers. Follow every step. No shortcuts.
## Active Missions
### MS21 — Multi-Tenant RBAC Data Migration (mosaic-stack) — ✅ COMPLETE
- **Tagged:** v0.0.21 on 2026-02-28
- **Deployed:** Production on w-docker0 (10.1.1.45), smoke tested via Playwright
- **PRs merged:** #559-#583 (25 PRs total)
- **Production fix applied:** Migration history table had only 6/29 entries; baselined all 29 + added MS21 user columns via direct SQL
- **Note:** TASKS.md final update PR (#584) blocked by branch protection (docs-only change doesn't trigger Woodpecker CI). Needs manual merge or adding docs/** to CI triggers.
- **Note:** Mosaic API hostname is `mosaic-api.woltje.com` (NOT `api.mosaic.woltje.com`)
### MS22 — Mosaic Stack Active Development (2026-03-01 Sprint)
- **Main branch**: #631 (fix noisy CSRF log)
- **Critical fix landed**: PR #630`import type` DTO bug in 6 controllers (root cause of Add Provider 400)
- **Deploy needed**: PRs #625#631 merged, CI building new image
- **6 agents running**: 3 GLM-5 (kanban, file-manager tags, project domain), 3 Codex (widget-flap, workspace-members, logs)
- **GLM-5 VALIDATED**: modelApplied:true confirmed, 3 concurrent ZAI sessions, near Opus SWE-bench
- **GLM-5 protocol**: review full diff + Jason approves before merge until trust established
- **MOSAIC_API_TOKEN expiry**: 2026-03-08 — renew before then
- **Full state**: memory/2026-03-01.md
### MS22 — Fleet Evolution (PLANNING)
- **Plan:** ~/src/jarvis-brain/docs/planning/FLEET-EVOLUTION-PLAN.md
- **Vision:** Multi-agent system with OpenClaw as runtime, Mosaic as management plane
- **Key insight:** Context loss solved via structured persistence (findings/memory tables in Postgres + pgvector), NOT chat mirroring
- **Agents collaborate through shared Task API + Findings API, not inter-agent chat**
- **Phase 0:** Knowledge layer (findings, agent_memory, task enhancements, conversation archive tables) + mosaic skill for agents
- **Phase 1:** Agent fleet standup (jarvis, builder, medic) in OpenClaw multi-agent
- **Phase 2:** WebUI chat + task management
- **Phase 3:** Multi-LLM provider management UI
- **Phase 4:** Scripted installer + non-technical UX
- **Next step:** Create PRD via `mosaic prdy init`, then create Mission MS22
- **Original vision doc:** ~/src/jarvis-brain/docs/planning/JARVIS-FLEET-EVOLUTION-V2.md
- **Agent personality files:** ~/src/jarvis-brain/agents/ (SHERLOCK.md, MEDIC.md, ALAN.md)
---
## Usage Monitoring
### How to Check Usage
- **Script:** `~/.config/mosaic/tools/telemetry/usage-report.sh [YYYY-MM-DD]`
- **Claude sessions:** Parse `~/.claude/projects/*//*.jsonl``usage.output_tokens`, `usage.cache_read_input_tokens`
- **Codex sessions:** Parse `~/.codex/sessions/YYYY/MM/DD/*.jsonl``payload.type=token_count` entries
- **Codex rate limits:** Same token_count entries have `rate_limits.primary.used_percent` (5h window) and `secondary.used_percent` (7d window)
- **OpenClaw session:** `session_status` tool shows current session token counts
- **Claude has NO exposed rate limit API** — track by output tokens as proxy; watch for 429 errors
### Claude Max Subscription
- Rate-limited, NOT pay-per-token
- All Claude surfaces (claude.ai, Claude Code, Claude Desktop, OpenClaw) share the SAME usage limit
- Max = 5x or 20x Pro usage (Jason's tier: TBD — ask if needed)
- Opus costs more rate limit budget than Sonnet; Sonnet costs more than Haiku
- **Implication:** Every Opus token I (the orchestrator) consume reduces budget for worker sessions
### Codex Max Subscription
- Rate-limited with 5h primary window and 7d secondary window
- Currently at 0% on both windows after earlier work
- Model: GPT-5.3-Codex-Spark
## 🎯 2026 Income Goal — MAJOR PRIORITY
**Target:** $100,000 additional net income (on top of day job salary)
### Income Streams
- **Work raise:** Aiming for $40-50K gross bump. ~30% tax penalty. Prorated for remaining year after granted. Status: pending.
- **DDK Consulting:** $100/hr (consider raising to $125-150), retainer clients preferred
- **ADHD/PDA Digital Products (Store B):** Strongest moat — lived experience with AuDHD+PDA, near-zero competition. Premium pricing ($49-199)
- **Digital Art (Store C / Pixels Etc):** 13,900+ clipart files ready to list. Fastest path to first dollar.
- **IT Compliance Templates (Store A):** 21 years IT experience = credibility. MSPs pay $200+ for compliance bundles.
- **SagePHR:** Q3 launch target, early adopter pricing
- **DYOR Platform:** Subscriptions + API + token utility
- **Affiliate Marketing:** IT tools (Claude, hosting, security) — authentic reviews + SEO
### Key Assets Already Owned
- Diverse Canvas LLC (active Kansas LLC with EIN + sales tax reg)
- pixels-etc.com domain + WordPress infrastructure
- 13,932 clipart files across ~10 themes (production-ready)
- 48 SVG coloring pages (KDP-ready)
- 13 email funnel templates
- 800+ product concepts with Midjourney prompts
- SEO launch checklist, ad benchmarks, social media playbook
### Deprioritized for 2026
- Flash-loan/arb bots (tech not ready)
- Afterlife (too early)
- Lark Path (longer timeline)
- Token launches (speculative)
### Execution Philosophy (PDA-Aware)
- Tiny steps — so small they don't trigger avoidance
- One thing at a time
- 15-minute minimum = win
- Ship ugly > perfect in head
- No guilt — pausing ≠ failing
- Jarvis remembers the plan so Jason doesn't have to hold it all
### Tracking
- AI-ROI Scoreboard: ~/src/jarvis-brain/domains/finances/ai-roi/codex/AI-ROI-SCOREBOARD.md
- Income strategy: ~/src/jarvis-brain/domains/finances/INCOME-DIVERSIFICATION-STRATEGY.md
- AI-ROI execution plan: ~/src/jarvis-brain/domains/finances/ai-roi/claude/EXECUTION-PLAN-UPDATED.claude.md
- ADHD/PDA market research: ~/src/jarvis-brain/domains/finances/ai-roi/claude/RD-ADHD-AUDHD-MARKET.claude.md
### Daily/Weekly Briefs
- **Daily 7:00 AM CST (Mon-Sat):** AI news, encouragement, 5 action items, status, adjustments, yesterday's wins
- **Sunday 7:00 AM CST:** Weekly recap replacing daily brief
- Cron IDs: daily=535c90c2, sunday=0a62dea9
## Preferences & Patterns
_(To be filled as I learn Jason's preferences)_