# ADR-001: NotebookLM as Orchestration Brain

## Status
Accepted

## Context
Claude Code operates in ephemeral sessions with limited context windows. Each session starts fresh without memory of prior decisions, architectural choices, or implementation rationale. This creates several problems:

- Decisions made during implementation evaporate when the session ends
- Architectural knowledge must be rediscovered or reconstructed
- Feedback loops and retros have no persistent store
- Specifications and research exist outside the execution context
- Multiple sessions on the same project lack continuity

We need a persistent orchestration memory that survives across sessions and serves as the canonical source of truth for all project knowledge, decisions, and specifications.

## Decision
Use NotebookLM Enterprise as the primary orchestration brain and memory system for CMS-aiChemist. Claude Code becomes an ephemeral executor that follows a strict PULL/EXECUTE/PUSH cycle:

1. **PULL** - Start each session by reading NotebookLM sources (via local handoffs/ mirror or API) to understand current project state, specs, and decisions
2. **EXECUTE** - Perform implementation work grounded in NotebookLM context, referencing specific source documents when making decisions
3. **PUSH** - After meaningful work, write new learnings, decisions, architectural changes, and feedback back to NotebookLM as new sources via the API

All durable knowledge, specs, decisions, feedback, and architectural state belong in NotebookLM. Claude Code's memory is treated as a lightweight cache, not a persistent store.

### Implementation Details
- **Account**: jonathan@noboxai.com
- **Notebook**: CMS-aiChemist (7d8b1917-4466-4f33-b5cf-7a8fb283f160)
- **Auth**: OAuth via gcloud auth print-access-token (separate from Gemini API key)
- **Local Mirror**: /home/jgatlit/apps/CMS/handoffs/ contains copies of all sources
- **Query Bridge**: Since NotebookLM has no direct chat API, use Gemini 2.5 Flash with source content as grounding context

## Consequences

### Positive
- Decisions and architectural knowledge survive session boundaries
- Multiple Claude Code sessions maintain continuity via shared brain
- Research, specs, and feedback have a canonical home
- Query patterns allow asking the brain for guidance at decision points
- 24 sources currently stored with STATUS_COMPLETE

### Negative
- Requires OAuth API integration (gcloud CLI dependency)
- No direct query API - must use Gemini bridge pattern
- Local mirror must be kept in sync with NotebookLM state
- API token expires and must be refreshed per session
- Additional cognitive overhead: must remember to PUSH learnings

### Neutral
- NotebookLM Enterprise requires Gemini Enterprise add-on (SUBSCRIPTION_TIER_NOTEBOOK_LM_INTERACT)
- API supports create/get/delete notebooks and batch add/delete/upload sources
- Source GET returns metadata only, not content - local mirror necessary
- Brain integration scripts: brain-query.sh, brain-push.sh, brain-status.sh
