# Oscar Platform — Runtime Inventory (Phase A0)

**Extracted:** 2026-06-29 11:20 UTC
**Purpose:** Source of truth for Recipe Book codex content (C1, C9)
**Schema:** `freshvibe-way-v8.runtime-inventory v1.0.0`

---

## 1. assistant/ (11 files, 888 LOC)

| File | LOC | Public exports | Purpose |
|---|---|---|---|
| `AssistantDock.tsx` | ~150 | `AssistantDock` | Root; wires SheetMin + SheetFull to askOscar() |
| `Bar.tsx` | ~50 | `Bar` | Bottom bar (dormant state) |
| `SheetMin.tsx` | ~120 | `SheetMin` | Peek state; quick input |
| `SheetFull.tsx` | ~250 | `SheetFull` | Full sheet; conversation history |
| `BackgroundNav.tsx` | ~80 | `BackgroundNav` | Cross-view nav bridges |
| `BackStack.ts` | 43 | `BackStack`, `push`, `pop` | Back navigation with anchor + context-switch emission |
| `state-machine.ts` | 73 | `applyTransition`, `TransitionTrigger` | State transitions for dock |
| `types.ts` | 70 | `DockState`, `Anchor`, `ChatMessage`, action types | Type definitions |
| `ask.ts` | 108 | `askOscar`, `AskResult` | Single entrypoint for assistant |
| `heuristics.ts` | 198 | `findHeuristic`, `HeuristicHit` | 25+ pre-baked answers |
| `memory.ts` | 54 | `ConversationMemory` | Module-level shared memory |
| `actions.ts` | 15 | `AssistantAction`, types | Action chips |
| `anchor-source.ts` | 183 | anchor source registry | Anchor surfaces |
| `web-search.ts` | 144 | `searchWeb`, `isWebSearchRequest` | Opt-in DDG search |
| `data/index.ts` | varies | `summarise()`, `DataSummary` | Data queries for assistant |
| `context.tsx` | varies | `useAssistantDockContext` | React context |

**Behaviour inventory (C1):**
- AssistantDock root → state = `bar` (default) → user taps → SheetMin → user expands → SheetFull
- BackStack preserves all anchors (push 1000, pop 999) per `runtime-checks.ts` RT-1.2
- 4 canonical anchor types: `custom`, `ai-answer`, `surface-context`, `system` (per RT-1.1)
- askOscar wraps provider config, dispatches to active adapter
- Heuristic layer: 25+ pre-baked answers with confidence scores (per `heuristics.ts`)
- Module-level shared memory (per `memory.ts`) — survives adapter re-creation
- Action chips: 4 types (navigate, open-item, compose, export)

**State machine (C2):**
States: `bar` → `sheet-min` → `sheet-full` → `peek`; transitions defined in `state-machine.ts`.
Transitions gated on `TransitionTrigger` (rail visibility, swipe-up, dismiss).

**Side effects (C3):**
- IDB writes via repo (when actions trigger save)
- localStorage: provider selection
- DOM updates: dock rendering, sheet open/close
- Network: optional web-search (opt-in DDG, fails on CORS per `web-search.ts`)

**Failure modes (C5):**
- Provider error → friendly error message via `askOscar` (never thrown to UI)
- IDB error → repository pattern catches and reports
- Web search CORS → honest failure message

---

## 2. brain/ (7 files, ~520 LOC)

| File | LOC | Public exports | Purpose |
|---|---|---|---|
| `index.ts` | | barrel | barrel |
| `rules/classify-tree.ts` | 167 | `classifyTree`, `ClassifyResult` | 10+ deterministic rules |
| `rules/check-compliance.ts` | 152 | `checkCompliance` | BS5837 minimum checks |
| `cached-standards.ts` | varies | `cachedStandards`, `getCached` | Pre-baked summaries |
| `orchestrator.ts` | varies | `orchestrate` | rules → cached → AI fallback |
| `post-processor.ts` | varies | `postProcess` | Output cleanup |
| `manifest.ts` | varies | `brainManifest`, `BrainChunk`, `BrainManifest` | Local LLM declaration (Qwen 0.5B Q4KM STUB) |
| `chunk-loader.ts` | varies | `loadChunk`, `verifyGgufMagic` | Chunked download |
| `download-manager.ts` | varies | `downloadBrain` | UI-triggered brain download |

**C1:** Rules engine first, cached lookup second, AI fallback third. Every output carries source provenance (`'rules' | 'cached' | 'ai-local' | 'ai-cloud'`).

**C2:** Brain has install state (not downloaded → downloaded → loading → ready → failed).

**C3:** IDB (chunk persistence via IDB chunks), localStorage (`brain-downloaded`).

**C5:** Chunk verify fails → mark failed; SHA-256 mismatch → reject.

**§15.3 CEILING VIOLATION:** Qwen 0.5B (500M params) exceeds 2M ceiling by 250×. See B1.1 §15.3-bis proposal.

---

## 3. data/ (11 files, ~880 LOC)

| File | LOC | Public exports | Purpose |
|---|---|---|---|
| `models/Tree.ts` | varies | `Tree`, retention category | Typed model |
| `models/Site.ts` | varies | `Site` | Typed model |
| `models/Survey.ts` | varies | `Survey` | Typed model |
| `models/Note.ts` | varies | `Note` | Typed model |
| `models/Report.ts` | varies | `Report` | Typed model |
| `models/BlogPost.ts` | varies | `BlogPost` | Typed model |
| `persistence/idb.ts` | varies | `getDb`, `OscarSchema`, `Repository` | IDB schema |
| `persistence/repo.ts` | varies | `Repository<T>`, repos | Repository pattern |
| `persistence/local-storage.ts` | varies | localStorage helpers | Namespaced storage |

**C1:** 6 stores, keyed by ULID; indexes per store.

**C9:** IDB schema is Oscar's most important state shape (every module depends on it).

**§02.1.1 REQUIREMENT:** Oscar's IDB schema must be declared as constitutional artefact (the `oscar.data.persistence.idb.001` fragment from README examples).

---

## 4. intelligence/ (13 files, ~1100 LOC)

| File | LOC | Public exports | Purpose |
|---|---|---|---|
| `ArboricultureProvider.ts` | ~70 | `ArboricultureProvider`, `createArboricultureProvider` | Provider wrapper |
| `adapters/stub.ts` | varies | stub adapter | canned responses |
| `adapters/smart.ts` | varies | smart adapter | 9-layer dispatcher |
| `adapters/local.ts` | varies | local adapter | Local Qwen (STUB) |
| `adapters/anthropic.ts` | varies | anthropic adapter | Claude API |
| `adapters/openai.ts` | varies | openai adapter | OpenAI API |
| `adapters/types.ts` | varies | `LlmAdapter`, request/response types | Adapter interface |
| `standards/BS5837.ts` | varies | plain-language summary | UK trees |
| `standards/BS3998.ts` | varies | summary | tree work |
| `standards/BS8545.ts` | varies | summary | trees + construction |
| `standards/AIA.ts` | varies | summary | Arboricultural Impact |
| `standards/AMS.ts` | varies | summary | Arboricultural Method |
| `standards/ARB.ts` | varies | summary | ARB code of ethics |
| `standards/library.ts` | varies | `StandardsLibrary`, `listStandards` | Standards container |
| `standards/system-prompt.ts` | varies | `arboricultureSystemPrompt` | System prompt |

**C1:** 5 adapters wrapped in `ArboricultureProvider` (per INT-1.1). Adapter activation via `setActiveAdapter`.

**C9:** Adapter provider ID = `oscar-arboriculture-provider`. 6 standards library complete.

---

## 5. views/ (6 files, ~3000 LOC)

| View | LOC | Routes | Pattern |
|---|---|---|---|
| `Home.tsx` | varies | `/` | Anchor grid |
| `Surveys.tsx` | varies | `/surveys` | List + modal editor |
| `Notes.tsx` | varies | `/notes` | List + modal editor (Phase 8) |
| `Reports.tsx` | varies | `/reports` | List + markdown editor + PDF/DOCX export (Phase 6/8) |
| `Settings.tsx` | varies | `/settings` | Provider select + theme + brain download + replay tour |
| `Blog.tsx` | 581 | `/blog` | List/editor/AI-assist (Phase 10) |

**C1:**
- Home: anchor chips that link to other views + AI draft deep link (`?ai=1`)
- Surveys: list surveys, create/edit/delete, modal editor with site, surveyor, date, weather, methodology, status, hazards, notes, tree list sub-editor
- Notes: textarea + save + tag extraction
- Reports: markdown body editor + load from survey data + PDF/DOCX export
- Settings: provider select, theme, brain download (UI only — no chunks), reset data, replay tour
- Blog: list/editor/AI-assist with tone controls (professional/casual/technical/storytelling), audience, word target, sections, markdown/preview tabs, .md/.html exports

---

## 6. writing/ (1 file, 237 LOC)

| File | LOC | Public exports | Purpose |
|---|---|---|---|
| `draft.ts` | 237 | `draftFullPost`, `draftOutline`, `draftSection`, `rewriteForTone`, `suggestTitle`, `suggestTags`, `generateSummary`, `blogToHtml`, `slugify`, `wordCount`, `readingMinutes` | AI blog writing |

**C1:** All entries route through `askOscar()` (single entrypoint, single cached adapter per Phase 8 fix).

**C3:** IDB writes via `postsRepo`; localStorage: provider; DOM: editor rendering.

**LATENT FEATURE:** Blog AI draft requires generative provider. Smart provider refuses. Operator must switch to Local/Anthropic/OpenAI in Settings.

---

## 7. shell/, branding/, ux/, export/, search/, onboarding/, settings/ (auxiliary)

| Module | LOC | Primary exports | Notes |
|---|---|---|---|
| `shell/` | varies | OscarShell, TopBar, Dock | 5-chip dock (Home, Surveys, Notes, Reports, Writing, Settings) |
| `branding/` | ~80 | palette, theme | Forest green + Cormorant Garamond |
| `ux/` | ~600 | EmptyState, CompletenessMeter, UndoToast (unwired), HelpTooltip, PlainLanguageLabel, StandardsLibrary | UndoToast exists but not wired (per Phase 8 audit) |
| `export/` | ~250 | PDF, DOCX | Reports only |
| `search/` | ~200 | Cmd+K | 7 kinds (view/survey/tree/note/report/standard/tool) |
| `onboarding/` | ~120 | Tour (5 steps) | Replay from Settings |
| `settings/` | varies | llm-config | Provider selection logic |

---

## END OF RUNTIME INVENTORY

*Per-module behaviour inventory. Used to write Recipe Books (Phase A2).*
