# Brain Dump v1 — Review Brief for Rafael

**Author:** Krillin (Saikan's technical co-pilot)
**For:** Rafael — review before M1 implementation starts
**Full plan:** `docs/brain-dump-v1-implementation-plan.md` (755 lines)
**Date:** 2026-06-17

---

## TL;DR (60 seconds)

We are going to build a thin layer inside saikan.io that surfaces the Google Drive content the bot pipeline already uploads — but **masticated, searchable, and taggable** — without the team ever having to leave the app to read a file. v1 ships only the Brain Dump. Planos and Discovery are deliberately deferred.

**Architecture (4 layers):**
- **L1 Drive** (unchanged) — bot keeps writing here, Guillermo keeps reading here
- **L2 Supabase Edge Function** (new) — polls Drive every 6h, calls MiniMax to summarize, writes to Supabase. Rate-limited to 1 file / 2s.
- **L3 Supabase Postgres** (new) — 4 tables: `brain_clients`, `brain_agents`, `brain_files`, `brain_processing_log`. RLS gated to 5 Saikan emails.
- **L4 saikan.io UI** (new) — client selector + Brain Dump list + detail view with embedded preview.

**Cost:** ~$0/month incremental. MiniMax is the team's provider, we rate-limit (not token-cap). Supabase free tier fits the v1 volume with a daily 600MB/1GB storage alert.

**Timeline:** 7–9 working days across 6 milestones (M0 backfill → M5 admin + alert).

---

## What changed since the last planning round

Recent context (this week, with Oliver on Telegram):

- Dropped the "duplicate everything to Supabase Storage" idea. Drive stays the binary source of truth, saikan.io is the cognitive layer.
- Dropped the "Plan + Discovery apps in v1" idea. v1 is only the Brain Dump.
- Locked MiniMax as the model provider.
- Locked polling (every 6h) over Drive webhooks — simpler, sufficient for 3 clients.
- Added a backfill trigger (M0) for day-1 historical context.
- Added a daily storage budget alert (M5) to stay under the 1GB Supabase free tier.

---

## The 15 locked decisions (read §2 of the full plan for rationale)

| # | Decision |
|---|----------|
| D1 | Only Brain Dump ships in v1; Planos and Discovery deferred |
| D2 | Schema supports N agents per client from day 1 |
| D3 | Drive = source of truth for binaries |
| D4 | Supabase = source of truth for cognitive metadata |
| D5 | saikan.io embeds files inline; "open in Drive" is secondary |
| D6 | MiniMax is the model provider, single call per file |
| D7 | All-in on Supabase (Edge Functions + pg_cron + RLS), no external services |
| D8 | Polling every 6h via pg_cron, not Drive webhooks |
| D9 | 5 Saikan team members only; clients never see saikan.io |
| D10 | No audio files; audio content already inside conversation transcripts |
| D11 | No monthly cap, no per-call cost tracking (MiniMax is the team's provider) |
| D12 | PDF size hard limit: 100MB |
| D13 | Storage alert at 600MB / 1GB (Supabase free tier) |
| D14 | Worker rate-limits to 1 file / 2s (configurable) |
| D15 | Backfill on demand per client (M0) |

---

## The 6 implementation milestones (read §7 for full breakdown)

| Milestone | Duration | What ships |
|-----------|----------|------------|
| M0 — Backfill trigger | ½ day | Manual "Initialize brain" Edge Function to ingest historical Drive content |
| M1 — Database & RLS | 1 day | Schema, RLS, seed data with 3 clients + 3 agents |
| M2 — Edge Function: poll + ingest | 2–3 days | The worker that polls Drive, summarizes, writes to Supabase |
| M3 — UI: list + client selector | 2 days | The Brain Dump list view with filters |
| M4 — UI: detail with embedded preview | 1–2 days | File detail view with inline preview + tag editor |
| M5 — Admin UI + storage alert | 1 day | `/admin` page, storage gauge, "Initialize brain" button, daily alert cron |

---

## What I want from Rafael specifically

Three things, in priority order:

1. **§6.4 — Drive preview strategy.** This is the one place where the design has not converged yet. Three options documented (A: anyone-with-link, B: saikan.io proxy, C: signed URLs). My recommendation is A; needs sign-off before M3.
2. **§2 D1 / §10 — Planos and Discovery deferred.** Confirm we're comfortable shipping only Brain Dump in v1. If you want any of the other apps started in parallel, flag it now — it changes the timeline and the DB design.
3. **§4 schema** — quick scan for anything missing (e.g. do you need an `archived_at` column? a `pinned` flag for important files? a `linked_plano_id` for cross-referencing? — I deliberately kept v1 minimal, but tell me if I'm under-designing).

---

## What I am NOT asking Rafael to validate (already locked or operational)

- 15 decisions in §2 (locked; the "why" is in the table)
- 6 milestones in §7 (locked timeline)
- 8 risks in §9 (each has a mitigation)
- The 10 deferred items in §10 (deferred deliberately, not forgotten)

---

## File map

- **`docs/brain-dump-v1-implementation-plan.md`** — the full 755-line plan. Read this if you want the details.
- **`docs/brain-dump-v1-REVIEW.md`** — this file. Read this first.
- **Repo root:** `D:\saikan.io\saikan.io\`
- **Branch:** `main` (clean working tree at time of writing)

---

## Open questions waiting for sign-off (from §11 of the full plan)

1. Email list for RLS (placeholders OK in v1)
2. First batch import — backfill all historical content (Oliver confirmed)
3. Drive preview sharing model (§6.4) — **Rafael, this one is yours**

Once those three are settled, M1 (schema) is unblocked and I can start writing migration SQL.
