# Aristotele — Human Setup TODO Checklist

Keep this guide alongside you when wiring up **Firebase AI Logic**, **Firebase Auth & Cloud Firestore (`ailogic-74fae`)**, **ADK-Rust (`adk-agent-loop/`)**, **Chrome Gemini Nano**, **`aristotele.vaked.dev` DNS**, **LAN nodes**, and **Devpost #BuildHybridAI 2026** submission assets. (Never commit private keys or `.env` files to git!)

---

## 0. Project `ailogic-74fae` Owner Checklist & Secret Rotation (~5 min)

> [!CAUTION]
> **Rotate Pasted Private Keys Immediately:** Because the Firebase Admin SDK service account JSON and Web Push VAPID private key were shared in chat history, rotate both before broad release:
> 1. In **Google Cloud Console -> IAM & Admin -> Service Accounts -> `firebase-adminsdk-fbsvc@ailogic-74fae.iam.gserviceaccount.com` -> Keys**, delete the previously pasted key ID (`4487dd96...` listed in `~/.aristotele/secrets/firebase-admin-ailogic-74fae.json`), create a new JSON key, and overwrite `/Users/peterlodri/.aristotele/secrets/firebase-admin-ailogic-74fae.json` (`chmod 600`).
> 2. In **Firebase Console -> Project Settings -> Cloud Messaging -> Web configuration -> Web Push certificates**, generate a new key pair, update `/Users/peterlodri/.aristotele/secrets/firebase-ailogic-74fae.env` (`chmod 600`), and replace `VAPID_PUBLIC_KEY` in `firebase-app/src/firebase-env.js` and `firebase-app/.env.*.example`.

### Already Provisioned on `ailogic-74fae` (`1031258784135`)
- **Production Web App (`Aristotele Studio`):** `1:1031258784135:web:bf91ebb9b86dc7395d5322`
- **Development Web App (`Aristotele Studio (Dev)`):** `1:1031258784135:web:444362aad8a51eb35d5322`
- **Local Secret Store (Outside Git, `chmod 700`/`600`):** `/Users/peterlodri/.aristotele/secrets/firebase-admin-ailogic-74fae.json` & `/Users/peterlodri/.aristotele/secrets/firebase-ailogic-74fae.env`

### Owner Permissions Required (Service Account Lacks `serviceusage.services.enable`)
1. **Enable APIs & Create Cloud Firestore:**
   - Open [Cloud Firestore Console (`ailogic-74fae`)](https://console.firebase.google.com/project/ailogic-74fae/firestore) and click **Create database** -> choose **(default)** in **Standard / Native mode** (enables `firestore.googleapis.com`).
2. **Enable Auth Sign-In Providers & Authorized Domains:**
   - Open [Authentication -> Sign-in method (`ailogic-74fae`)](https://console.firebase.google.com/project/ailogic-74fae/authentication/providers), enable **Email/Password** and **Google** (select project support email; enables `identitytoolkit.googleapis.com`).
   - Under **Authentication -> Settings -> Authorized domains**, ensure `localhost`, `127.0.0.1`, `8b-is.github.io`, `aristotele.vaked.dev`, `ailogic-74fae.web.app`, and `ailogic-74fae.firebaseapp.com` are listed.
3. **Interactive CLI Deploy (Rules, Indexes, Auth Config, Hosting):**
   ```sh
   cd firebase-app
   npx -y firebase-tools@latest login
   npm run deploy:rules
   npm run deploy:auth
   npm run deploy:prod
   ```
4. **Provision BigQuery Telemetry Datasets (`dev` vs `prod`):**
   ```sh
   bq mk --dataset --location=US ailogic-74fae:aristotele_dev
   bq mk --dataset --location=US ailogic-74fae:aristotele_prod
   bq query --project_id=ailogic-74fae --use_legacy_sql=false < firebase-app/analytics/bigquery-schema.sql
   ```
5. **Run Local Dev Emulators + ADK-Rust Behind-the-Scenes Agent Loop:**
   ```sh
   # Terminal A: Local Auth (:9099), Firestore (:8180), Hosting (:5175), Emulator UI (:4100)
   cd firebase-app && npm run dev:emulators

   # Terminal B: Offline check or live Gemini / Ollama ADK-Rust loop with Aristotele MCP tools
   cargo run --manifest-path adk-agent-loop/Cargo.toml -- --check --env dev
   # With live Gemini key:
   # GOOGLE_API_KEY=... cargo run --manifest-path adk-agent-loop/Cargo.toml -- --env prod --provider gemini --prompt "Inspect SPHIST/1 status"
   ```

---

## 1. Firebase Console & Firebase AI Logic Setup (~5 min)

1. Go to the [Firebase Console](https://console.firebase.google.com/) and create or select your project.
2. Open **AI Logic** (`Build -> AI Logic` or `https://console.firebase.google.com/project/_/ailogic/`).
3. Choose and enable at least one Gemini API provider:
   - **Gemini Developer API (Recommended to start fast — Free Tier available):** click **Enable** under *Gemini Developer API*. Matches Aristotele's `google_ai` (`GoogleAIBackend`) mode.
   - **Agent Platform Gemini API (formerly Vertex AI in Firebase):** click **Enable** if your project is on Blaze and you want enterprise quotas/grounding SLAs. Matches Aristotele's `agent_platform` (`AgentPlatformBackend`) mode.
4. Register a **Web App** in **Project Settings -> Your apps -> Add app (`</>`)**, copy the `firebaseConfig` JSON (`apiKey`, `authDomain`, `projectId`, `appId`), and paste it into:
   - **Studio WebApp -> AI Models -> Firebase AI Logic -> Paste Firebase Config JSON -> Save & Enable**, OR
   - `~/.aristotele/firebase.json` if scripting locally.
5. *(Optional toggles in Studio)*:
   - Check **Ground with Google Search** to attach `{ googleSearch: {} }` citations to cloud Gemini responses.
   - Keep **Enable WebMCP Function Calling** checked when you want Gemini to call `local_hardware_probe`, `maple_20b_a1b_probe`, `memory_palace_search`, and `session_export_markdown` (note: Gemini API separates built-in `googleSearch` from custom `functionDeclarations`, so uncheck Search Grounding when testing WebMCP function calls).

---

## 2. Firebase App Check (Protect Your Gemini Quota)

1. In Firebase Console -> **Build -> App Check**, register a **reCAPTCHA Enterprise** provider for your Web App (or domain `aristotele.vaked.dev` + `127.0.0.1` / `localhost`).
2. Copy the reCAPTCHA Enterprise **Site Key** into Studio's **App Check Site Key** input.
3. Keep **Enable App Check Debug Token for Localhost** checked while developing on `http://127.0.0.1:1337`; inspect DevTools Console for the printed Firebase debug UUID and add it under **App Check -> Apps -> Manage debug tokens** in Firebase Console.

---

## 3. Firebase Hosting Deploy (`firebase-app/`)

If you also want `https://<your-project>.web.app` serving Aristotele Studio + discovery files:

```sh
cd firebase-app
npx firebase-tools login
npx firebase-tools use <YOUR_FIREBASE_PROJECT_ID>
npx firebase-tools deploy --only hosting
```

---

## 4. Custom Domain DNS (`aristotele.vaked.dev`)

`dig` currently shows `aristotele.vaked.dev` resolves to Cloudflare apex proxy IPs with no `CNAME` record yet, so the repo includes `docs/CNAME.aristotele.vaked.dev` without prematurely activating a broken `docs/CNAME`.

Once ready to go live on `https://aristotele.vaked.dev`:

1. In **Cloudflare DNS** for `vaked.dev`, add record:
   - **Type:** `CNAME`
   - **Name:** `aristotele`
   - **Target:** `8b-is.github.io`
   - **Proxy status:** DNS only (grey cloud) initially while GitHub provisions the TLS certificate, then optionally Proxied (`Full (strict)` SSL).
2. Enable GitHub Pages custom domain:
   ```sh
   git mv docs/CNAME.aristotele.vaked.dev docs/CNAME
   git commit -m "chore(pages): enable aristotele.vaked.dev custom domain"
   git push origin main
   ```
3. In **GitHub -> `8b-is/aristotele` -> Settings -> Pages**, confirm `aristotele.vaked.dev` shows HTTPS **Enforced**.

---

## 5. Chrome Built-In Gemini Nano & WebMCP Flags (Desktop Chrome)

For true zero-cloud **On-Device** browser inference (`window.LanguageModel`) and native `navigator.modelContext`:

1. Open `chrome://flags/#optimization-guide-on-device-model` -> set **Enabled BypassPerfRequirement**.
2. Open `chrome://flags/#prompt-api-for-gemini-nano` -> set **Enabled** (or **Enabled Multilingual**).
3. *(Optional WebMCP preview)* Open `chrome://flags` and enable `web-machine-learning` / WebMCP flags if available in your Chrome build.
4. Relaunch Chrome, open `chrome://on-device-internals`, trigger model download if status is `downloadable`, then click **Open Studio** — the top-bar pill switches to **Chrome Gemini Nano: available**.

---

## 6. LAN / Offline / Maple 20B-A1B Local Server Setup

Choose any private inference node (no cloud account required):

- **Air-Gapped Local (Built-in Kolibry / Maple Probe):**
  ```sh
  aristotele --local-only app
  ```
- **Ollama on Localhost or LAN (`http://<LAN_IP>:11434/v1`):**
  ```sh
  OLLAMA_HOST=0.0.0.0:11434 ollama serve
  ollama pull qwen2.5-coder:7b
  aristotele --provider http://127.0.0.1:11434/v1 --model qwen2.5-coder:7b app
  ```
- **Maple 20B-A1B Ternary MoE (`ggml-org/llama.cpp#27000`):**
  ```sh
  llama-server -hf deepgrove/maple-preview --port 8080
  aristotele --provider maple app
  ```
- **Studio UI Wizard:** Go to **AI Models -> LAN / On-Device / Offline Setup Wizard**, pick a preset (`Ollama`, `vLLM`, `Maple`, or `Air-Gapped Local`), or type a custom LAN URL and click **Save & Switch Primary**.

---

## 7. BuildHybridAI 2026 Devpost Submission Checklist

1. Confirm live URLs respond HTTP `200`:
   - `https://8b-is.github.io/aristotele/` (and `https://aristotele.vaked.dev/` after Step 4)
   - `https://aristotele.vaked.dev/studio.html`
   - `https://aristotele.vaked.dev/llms.txt` & `.well-known/mcp.json`
2. Record a 60–90s demo video showing:
   - Top-bar routing switch (`Hybrid Auto` -> `Private Only` -> `Cloud First`) + Multimodal attachment (Image/PDF)
   - Google Search Grounding / WebMCP `local_hardware_probe` + 1-click Skills
   - Maple 20B-A1B benchmark (`POST /v1/maple/bench` or `aristotele bench`)
   - `Cmd+K` Command Palette + Security Posture card.
3. Paste text/links from `docs/DEVPOST_SUBMISSION.md` into Devpost!
