OSVauco/MASTERPLAN.md
2026-05-27 19:13:54 +00:00

282 lines
8.6 KiB
Markdown

# VAUCO MASTERPLAN — Chris Christiansen
**Sist oppdatert: 2026-05-27 20:30 CEST**
**Status: ✅ FASE A | ✅ FASE B | ✅ ML-1 | ✅ CG1+CG2 live | ✅ OAuth live | CG3 neste**
> **Les dette først:** Autoritativ arkitektur er `vauco-os/VAUCO_OS_DOMAIN_ARCHITECTURE.md`.
> Ikke overstyr beslutninger som allerede er dokumentert der.
---
## ARKITEKTUR-HIERARKI (autoritetivt)
```
Vauco AS (935 989 779)
├── Vauco OS ← internt operativsystem (kun Chris)
│ ├── os.vauco.no ← LIVE PROD
│ ├── oss.vauco.no ← STAGING (nåværende arbeidsområde)
│ ├── Jason (autonom agent)
│ ├── Vauco OS Hub (orchestrator)
│ └── Cloud Console ← salgsmoduler bygges herfra
│ └── CostGuard ← modul #1 (use case + første salgbar modul)
│ costguard.oss.vauco.no ← nåværende
│ costguard.os.vauco.no ← når live
└── Threadstone ← separat SaaS-produkt til kunder
threadstone.vauco.no
app.threadstone.vauco.no
```
**CostGuard er et use case som beviste OPAX-arkitekturen.**
Det bygges simultant med OPAX som modul #1 i Cloud Console.
Medioteq og fremtidige kunder onboardes av deg selv via OPAX innenfra — ikke her.
---
## REPO-OVERSIKT
| Repo | Hva det er |
|---|---|
| `OSVauco` | Kjerne: Cloud Run agent, GCP-scripts, ml/, auth/ |
| `vauco-gemini-tui-bridge` | TUI-cockpit (langt arbeid → bruk Gemini TUI) |
| `vauco-os` | Arkitektur og kundedok (authoritative) |
| `vauco-bootstrap` | Terraform-modul for kunde-provisjonering |
| `deep-dream` | Strategisk visjon — aldri deploy herfra |
---
## AGENT-IDENTITET
| Identitet | E-post | Rolle | Formål |
|---|---|---|---|
| Eier / admin | `chris.christiansen@vauco.no` | `billing.admin` + `billing.viewer` | Full kontroll |
| Agent (OPAX) | `jason.vauger@vauco.no` | `billing.viewer` | Hente og rapportere kostnadsdata autonomt |
| Fremtidig gruppe | `billing@vauco.no` | `billing.viewer` (Fase C) | Delt innboks for team og kunder |
**Agent-kapabiliteter med `billing.viewer`:**
- Svare på «Hva koster dette prosjektet denne måneden?»
- Sende ukentlig kostnadsrapport til chat-appen
- Reagere på Pub/Sub budget-alerts (via `10-cost-guard.sh`)
- **Ikke:** endre IAM, budsjetter eller koble prosjekter
---
## DNS / DOMENE-ARKITEKTUR
> **Arkitekturavgjørelse — 2026-05-26**
| Domene | Type | Teknologi | Fase |
|---|---|---|---|
| `opax.vauco.no` | Intern cockpit (kun Chris) | CNAME → Cloud Run (gratis) | B1 nå |
| `costguard.oss.vauco.no` | Standalone app | CNAME → osvauco-agent-357036551735.europe-west1.run.app | CG3 |
| `kunde1.vauco.no` / kundedomener | Kunde-instanser | LB + IAP (Terraform) | Fase C |
**Begrunnelse:**
- `opax.vauco.no` er et internt arbeidsverktøy for én bruker — Load Balancer ($18-20/mnd) er unødvendig overhead.
- Kundeinstanser provisjoneres via `vauco-bootstrap` Terraform-modul i Fase C. LB + IAP bakes inn i modulen én gang og kjøres automatisk per kunde med `terraform apply -var="customer_id=X"`.
- Terraform-modulen (Fase C) skal inkludere: Cloud Run, Cloud Build, IAP, LB, budsjett, SA, Dialogflow CX, ML state store.
---
## CLOUD SHELL QUICK-START (kopi-klipp)
> Bruk Cloud Shell: https://shell.cloud.google.com
```bash
# Steg 1: Klon og sett opp miljø
gcloud config set project propane-will-491900-m5
git clone https://github.com/vauco-saas/OSVauco.git ~/OSVauco
cd ~/OSVauco
# Steg 2: Kopier og rediger .env
cp .env.example .env
nano .env
# Fyll ut: BILLING_ACCOUNT_ID, ALERT_EMAIL, GITHUB_APP_INSTALLATION_ID
# Steg 3: Installer Python-avhengigheter
pip install google-adk google-cloud-aiplatform>=1.111.0 --quiet
# Steg 4: Kjør i rekkefølge
source .env
bash infrastructure/00-authcheck.sh
bash infrastructure/01-setupenv.sh
bash infrastructure/07-rag-setup.sh
# *** Kopier RAG_CORPUS_NAME fra output inn i .env ***
nano .env && source .env
bash infrastructure/08-memorybank-setup.sh
# *** Kopier MEMORY_ENGINE_NAME fra output inn i .env ***
nano .env && source .env
gcloud run deploy osvauco-agent
--source . --region europe-west1
--project propane-will-491900-m5
--set-secrets RAG_CORPUS=rag-corpus-name:latest
--set-env-vars GOOGLE_GENAI_USE_VERTEXAI=1,GOOGLE_CLOUD_PROJECT=propane-will-491900-m5,GOOGLE_CLOUD_LOCATION=global,MEMORY_ENGINE_NAME=$MEMORY_ENGINE_NAME
--no-allow-unauthenticated
bash infrastructure/04-observability-setup.sh
bash infrastructure/11-billing-iam-hardening.sh
bash scripts/smoke-test.sh
# Om kvelden (OBLIGATORISK):
bash infrastructure/03-teardown.sh
```
---
## CLOUD RUN — LIVE ENDEPUNKTER
**Service:** `osvauco-agent` | **Region:** `europe-west1`
**URL:** `https://osvauco-agent-357036551735.europe-west1.run.app`
**Siste revisjon:** `osvauco-agent-00064-p9h`
| Endepunkt | Status | Beskrivelse |
|---|---|---|
| `GET /health` | ✅ | Health check |
| `POST /run` | ✅ | Agent (light/heavy) |
| `POST /run/dag` | ✅ | Parallell DAG |
| `GET /billing/summary` | ✅ | Kostnad per tjeneste siste 30d |
| `GET /billing/forecast` | ✅ | Prognose 7d snitt |
| `GET /billing/anomalies` | ✅ | Anomali-deteksjon + Pub/Sub |
| `GET /auth/login?client_id=X` | ✅ | Start OAuth2-flow |
| `GET /auth/callback` | ✅ | Google redirect → token |
| `GET /static/billing-dashboard.html` | ✅ | Billing dashboard UI |
| `GET /state` | ✅ | Agent state |
| `GET /telemetry/history` | ✅ | Telemetri |
**OAuth (Vauco OS Web App):**
- Client ID: `357036551735-ka7t2fv9ue2jp01bs826hpdctlvispuo.apps.googleusercontent.com`
- Redirect URI: `https://osvauco-agent-357036551735.europe-west1.run.app/auth/callback`
- Secrets: `OAUTH_CLIENT_ID`, `OAUTH_CLIENT_SECRET` (Secret Manager)
**BigQuery:** `propane-will-491900-m5:billing_export` — tabell ventes innen 24t fra 2026-05-27
---
## FASE CG — CostGuard (OPAX modul #1) ← AKTIV
```
[x] CG1 — ml/billing_agent.py: /billing/summary, /forecast
[x] CG2 — ml/anomaly_detector.py: anomali → Pub/Sub
[x] AUTH — OAuth2 flow live
[ ] CG3 — costguard.oss.vauco.no landingsside
static/costguard.html i OSVauco-repo
"Koble til GCP" → /auth/login
Billing dashboard embed
CNAME costguard.oss.vauco.no → Cloud Run
(promoveres til costguard.os.vauco.no når klar)
[ ] CG4 — Første ekstern kunde via vauco-bootstrap
[ ] CG5 — Salgsdemo klar
```
---
## FASE A — ✅ KOMPLETT
```
[x] A1-A9 + SMOKE 10/10 ✅ (2026-05-26 01:45 CEST)
RAG: projects/357036551735/locations/europe-west1/ragCorpora/6917529027641081856
Memory: projects/357036551735/locations/us-central1/reasoningEngines/2260229219579592704
```
---
## FASE A2 — Dialogflow CX (Jason-v1 FAQ)
```
[x] DX1-DX3 — Agent live, Data Store, norsk systemprompt
[x] DX4 — Parkert (Cloud Run-webhook til C4)
[ ] DX5 — Dialogflow Messenger (trigger: CG3)
[ ] DX6 — Budsjett-alert
[ ] DX7 — Voice-kanal (trigger: etter DX5)
[ ] B6 — Eksporter Dialogflow CX til versjonskontroll
```
---
## FASE ML
```
[x] ML-1 — DAG, state store, telemetri ✅ (2026-05-25)
[ ] ML-2 — Adaptiv intelligens (trigger: >500 telemetri-kall)
[ ] ML-3 — Strategisk innsikt (trigger: ML-2 + første kunde)
```
---
## FASE B — ✅ KOMPLETT
```
[x] B1-B5, B1-IAP (opax.vauco.no CNAME live)
[ ] B6 — Dialogflow CX versjonskontroll (se DX-lista)
```
---
## FASE C — Kunde-onboarding
> Medioteq og fremtidige kunder håndteres av deg selv via OPAX.
```
[x] C1 — vauco-bootstrap Terraform-modul (validate: PASS)
[x] C2 — CUSTOMER_API.md
[x] C3 — billing@vauco.no Google Group
[ ] C4 — Medioteq: HITL-møte → project_id → terraform apply
```
---
## INFRASTRUKTUR
| Script | Rolle |
|--------|-------|
| `00-authcheck.sh` | Verifiser innlogging |
| `01-setupenv.sh` | APIs, SA, IAM, Pub/Sub |
| `03-teardown.sh` | Riv ned Cloud Run (kjør hver kveld) |
| `04-observability-setup.sh` | Cloud Monitoring |
| `07-rag-setup.sh` | RAG corpus |
| `08-memorybank-setup.sh` | Memory Bank |
| `10-cost-guard.sh` | Auto-teardown + GCS telemetri |
| `11-billing-iam-hardening.sh` | IAM hardening |
| `scripts/smoke-test.sh` | 10-case røyktest |
---
## KJENTE HULL
| ID | Hva | Status |
|---|---|---|
| OQ-01 | Memory Bank — ingen gcloud CLI | Python SDK only |
| OQ-02 | RAG regional | Auto-fallback us-east1 |
| OQ-15 | billing_export BQ-tabell | Venter — aktivert 2026-05-27 |
---
## DRIFTSKOSTNADER
| Scenario | Kostnad/mnd |
|---|---|
| Dev (teardown daglig) | ~$25-75 |
| Dev + Dialogflow CX (10k req) | ~$145-195 |
| 1 betalende kunde | ~$115-280 |
Breakeven: 1 kunde à $300-500/mnd.
---
## LLM-RUTING
| Modell | Bruksområde |
|---|---|
| `gemini-2.5-flash` | light — alle enkle kall |
| `gemini-2.5-pro` | heavy — reasoning, compliance |
`LOCATION=global` | Autoriserte heavy: `opax`, `admin`
---
*OSVauco | propane-will-491900-m5 | europe-west1*