From 25ee2d495a5ffcff14ffe12feaccb65a589a1222 Mon Sep 17 00:00:00 2001 From: Chris Christiansen Date: Tue, 26 May 2026 13:36:59 +0000 Subject: [PATCH] feat: opax-mcp modul-struktur, acceptance-test og preflight-check scripts --- agents/core-logic/deploy_agent.py | 0 agents/eval/run_eval.py | 0 agents/tests/test_local.sh | 0 docs/TODO.md | 2 +- infrastructure/01-setupenv.sh | 0 infrastructure/02-deploy.sh | 0 infrastructure/03-teardown.sh | 0 infrastructure/04-observability-setup.sh | 0 infrastructure/05-cloudrun-deploy.sh | 0 infrastructure/06-cicd-setup.sh | 0 infrastructure/07-rag-setup.sh | 0 infrastructure/08-memorybank-setup.sh | 0 infrastructure/09-cost-check.sh | 0 infrastructure/10-cost-guard.sh | 0 infrastructure/11-billing-iam-hardening.sh | 0 infrastructure/12-rag-integration.sh | 0 infrastructure/99-region-guard.sh | 0 .../terraform/cost-guard-fn/main.py | 0 main.py | 0 opax-mcp/README.md | 1 + opax-mcp/__init__.py | 0 opax-mcp/pyproject.toml | 8 ++ scripts/acceptance-test.sh | 77 +++++++++++++++++++ scripts/bootstrap.sh | 0 scripts/preflight-check.sh | 73 ++++++++++++++++++ scripts/smoke-test.sh | 0 26 files changed, 160 insertions(+), 1 deletion(-) mode change 100755 => 100644 agents/core-logic/deploy_agent.py mode change 100755 => 100644 agents/eval/run_eval.py mode change 100755 => 100644 agents/tests/test_local.sh mode change 100755 => 100644 infrastructure/01-setupenv.sh mode change 100755 => 100644 infrastructure/02-deploy.sh mode change 100755 => 100644 infrastructure/03-teardown.sh mode change 100755 => 100644 infrastructure/04-observability-setup.sh mode change 100755 => 100644 infrastructure/05-cloudrun-deploy.sh mode change 100755 => 100644 infrastructure/06-cicd-setup.sh mode change 100755 => 100644 infrastructure/07-rag-setup.sh mode change 100755 => 100644 infrastructure/08-memorybank-setup.sh mode change 100755 => 100644 infrastructure/09-cost-check.sh mode change 100755 => 100644 infrastructure/10-cost-guard.sh mode change 100755 => 100644 infrastructure/11-billing-iam-hardening.sh mode change 100755 => 100644 infrastructure/12-rag-integration.sh mode change 100755 => 100644 infrastructure/99-region-guard.sh mode change 100755 => 100644 infrastructure/terraform/cost-guard-fn/main.py mode change 100755 => 100644 main.py create mode 100644 opax-mcp/README.md create mode 100644 opax-mcp/__init__.py create mode 100644 opax-mcp/pyproject.toml create mode 100644 scripts/acceptance-test.sh mode change 100755 => 100644 scripts/bootstrap.sh create mode 100644 scripts/preflight-check.sh mode change 100755 => 100644 scripts/smoke-test.sh diff --git a/agents/core-logic/deploy_agent.py b/agents/core-logic/deploy_agent.py old mode 100755 new mode 100644 diff --git a/agents/eval/run_eval.py b/agents/eval/run_eval.py old mode 100755 new mode 100644 diff --git a/agents/tests/test_local.sh b/agents/tests/test_local.sh old mode 100755 new mode 100644 diff --git a/docs/TODO.md b/docs/TODO.md index 72cfc21..d20ed73 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -7,7 +7,7 @@ ## NOW - [x] **⚠️ HASTER** — Roter OAuth client secret `Vauco OS Web App` i [Google Auth Platform](https://console.cloud.google.com/auth/clients/357036551735-ka7t2fv9ue2jp01bs826hpdctlvispuo.apps.googleusercontent.com?project=propane-will-491900-m5) — eksponert i chat 2026-05-25. (Løst) -- [ ] Vurder om `jason.vauger@vauco.no` skal beholde `roles/run.invoker` på `osvauco-agent`. +- [x] Vurder om `jason.vauger@vauco.no` skal beholde `roles/run.invoker` på `osvauco-agent`. (Konklusjon: Ja, nødvendig for feedback_loop.py) - [x] Kjør `git update-index --chmod=+x` på alle scripts + commit — hindrer Permission denied etter GitHub web-edit. - [ ] Verifiser første nattlige GDrive backup — kl 03:00 UTC (Actions-logg). diff --git a/infrastructure/01-setupenv.sh b/infrastructure/01-setupenv.sh old mode 100755 new mode 100644 diff --git a/infrastructure/02-deploy.sh b/infrastructure/02-deploy.sh old mode 100755 new mode 100644 diff --git a/infrastructure/03-teardown.sh b/infrastructure/03-teardown.sh old mode 100755 new mode 100644 diff --git a/infrastructure/04-observability-setup.sh b/infrastructure/04-observability-setup.sh old mode 100755 new mode 100644 diff --git a/infrastructure/05-cloudrun-deploy.sh b/infrastructure/05-cloudrun-deploy.sh old mode 100755 new mode 100644 diff --git a/infrastructure/06-cicd-setup.sh b/infrastructure/06-cicd-setup.sh old mode 100755 new mode 100644 diff --git a/infrastructure/07-rag-setup.sh b/infrastructure/07-rag-setup.sh old mode 100755 new mode 100644 diff --git a/infrastructure/08-memorybank-setup.sh b/infrastructure/08-memorybank-setup.sh old mode 100755 new mode 100644 diff --git a/infrastructure/09-cost-check.sh b/infrastructure/09-cost-check.sh old mode 100755 new mode 100644 diff --git a/infrastructure/10-cost-guard.sh b/infrastructure/10-cost-guard.sh old mode 100755 new mode 100644 diff --git a/infrastructure/11-billing-iam-hardening.sh b/infrastructure/11-billing-iam-hardening.sh old mode 100755 new mode 100644 diff --git a/infrastructure/12-rag-integration.sh b/infrastructure/12-rag-integration.sh old mode 100755 new mode 100644 diff --git a/infrastructure/99-region-guard.sh b/infrastructure/99-region-guard.sh old mode 100755 new mode 100644 diff --git a/infrastructure/terraform/cost-guard-fn/main.py b/infrastructure/terraform/cost-guard-fn/main.py old mode 100755 new mode 100644 diff --git a/main.py b/main.py old mode 100755 new mode 100644 diff --git a/opax-mcp/README.md b/opax-mcp/README.md new file mode 100644 index 0000000..ceabe30 --- /dev/null +++ b/opax-mcp/README.md @@ -0,0 +1 @@ +OPAX MCP-modul for OSVauco \ No newline at end of file diff --git a/opax-mcp/__init__.py b/opax-mcp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/opax-mcp/pyproject.toml b/opax-mcp/pyproject.toml new file mode 100644 index 0000000..e65f3b8 --- /dev/null +++ b/opax-mcp/pyproject.toml @@ -0,0 +1,8 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "opax-mcp" +version = "0.0.1" +description = "OPAX MCP module for OSVauco" diff --git a/scripts/acceptance-test.sh b/scripts/acceptance-test.sh new file mode 100644 index 0000000..18762db --- /dev/null +++ b/scripts/acceptance-test.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +# acceptance-test.sh — Full boot cycle acceptance test for OSVauco OPAX + +set -euo pipefail + +# --- Configuration & Helpers --- + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.." + +# Default to no cleanup +CLEANUP=false + +# Parse command-line arguments +for arg in "$@" +do + case $arg in + --cleanup) + CLEANUP=true + shift # Remove --cleanup from processing + ;; + esac +done + +echo_step() { + echo "" + echo "==================================================================" + echo "=> $1" + echo "==================================================================" +} + +# --- Main Test Flow --- + +# Step 1: Source environment variables if .env file exists +echo_step "Loading environment..." +if [ -f "$ROOT_DIR/.env" ]; then + source "$ROOT_DIR/.env" + echo ".env file loaded." +else + echo "WARNING: .env file not found. Script may fail if required variables are not set." +fi + +# Step 2: Run setup scripts +echo_step "Phase 1: Infrastructure Setup" +bash "$ROOT_DIR/infrastructure/00-authcheck.sh" +bash "$ROOT_DIR/infrastructure/01-setupenv.sh" +bash "$ROOT_DIR/infrastructure/07-rag-setup.sh" +bash "$ROOT_DIR/infrastructure/08-memorybank-setup.sh" +bash "$ROOT_DIR/infrastructure/04-observability-setup.sh" +bash "$ROOT_DIR/infrastructure/11-billing-iam-hardening.sh" + +# Step 3: Deploy the Cloud Run service +# Note: This assumes RAG_CORPUS_NAME and MEMORY_ENGINE_NAME are correctly set in .env +echo_step "Phase 2: Cloud Run Deployment" +gcloud run deploy osvauco-agent + --source . --region europe-west1 + --project "${GCLOUD_PROJECT_ID?GCLOUD_PROJECT_ID not set}" + --set-secrets "RAG_CORPUS=${RAG_CORPUS_NAME?RAG_CORPUS_NAME not set}:latest" + --set-env-vars "GOOGLE_GENAI_USE_VERTEXAI=1,GOOGLE_CLOUD_PROJECT=${GCLOUD_PROJECT_ID},GOOGLE_CLOUD_LOCATION=global,MEMORY_ENGINE_NAME=${MEMORY_ENGINE_NAME?MEMORY_ENGINE_NAME not set}" + --no-allow-unauthenticated + +# Step 4: Run the smoke test to verify the deployment +echo_step "Phase 3: API Smoke Test" +bash "$ROOT_DIR/scripts/smoke-test.sh" + +# Step 5: Optional Teardown +if [ "$CLEANUP" = true ]; then + echo_step "Phase 4: Tearing down Cloud Run service..." + bash "$ROOT_DIR/infrastructure/03-teardown.sh" + echo "Teardown complete." +else + echo_step "Skipping teardown. Run 'bash infrastructure/03-teardown.sh' manually to clean up." +fi + +echo "" +echo "==================================================================" +echo "✅✅✅ Acceptance Test Completed Successfully ✅✅✅" +echo "==================================================================" diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh old mode 100755 new mode 100644 diff --git a/scripts/preflight-check.sh b/scripts/preflight-check.sh new file mode 100644 index 0000000..145b2a3 --- /dev/null +++ b/scripts/preflight-check.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +# preflight-check.sh — Verifies the local development environment for OSVauco OPAX. + +set -euo pipefail + +# --- Configuration & Helpers --- +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.." +FAIL_COUNT=0 + +step_info() { echo "[INFO] $1"; } +step_ok() { echo " ✅ $1"; } +step_fail() { + echo " ❌ $1" + FAIL_COUNT=$((FAIL_COUNT + 1)) +} + +# --- Preflight Checks --- + +echo "==================================================================" +echo "=> Running OSVauco Preflight Checks" +echo "==================================================================" + +# Check 1: gcloud authentication and project config +step_info "Checking GCP authentication..." +if bash "$ROOT_DIR/infrastructure/00-authcheck.sh" &>/dev/null; then + step_ok "gcloud is authenticated and project is set." +else + step_fail "gcloud authentication or project is not configured. Run 'gcloud auth login' and 'gcloud config set project '." +fi + +# Check 2: .env file existence +step_info "Checking for .env file..." +if [ -f "$ROOT_DIR/.env" ]; then + step_ok ".env file found." + # Source it for the next check + source "$ROOT_DIR/.env" +else + step_fail ".env file not found. Please copy .env.example to .env and fill in the required values." +fi + +# Check 3: Critical Environment Variables +step_info "Checking critical environment variables..." +if [ -n "${GCLOUD_PROJECT_ID-}" ] && [ -n "${BILLING_ACCOUNT_ID-}" ]; then + step_ok "Required environment variables (GCLOUD_PROJECT_ID, BILLING_ACCOUNT_ID) are set." +else + step_fail "One or more required variables (GCLOUD_PROJECT_ID, BILLING_ACCOUNT_ID) are not set in your .env file." +fi + +# Check 4: Python dependencies hint +step_info "Checking for Python dependencies..." +if [ -f "$ROOT_DIR/requirements.txt" ]; then + step_ok "requirements.txt found. Ensure dependencies are installed with 'pip install -r requirements.txt'." +else + step_fail "requirements.txt not found." +fi + +# Check 5: Git working directory status +step_info "Checking Git status..." +if git -C "$ROOT_DIR" diff --quiet && git -C "$ROOT_DIR" diff --cached --quiet; then + step_ok "Git working directory is clean." +else + step_fail "Git working directory has uncommitted changes. Please commit or stash them." +fi + +# --- Summary --- +echo "==================================================================" +if [ $FAIL_COUNT -eq 0 ]; then + echo "✅✅✅ Preflight checks passed successfully! ✅✅✅" + exit 0 +else + echo "❌❌❌ Preflight checks failed with $FAIL_COUNT error(s). Please resolve them and re-run. ❌❌❌" + exit 1 +fi diff --git a/scripts/smoke-test.sh b/scripts/smoke-test.sh old mode 100755 new mode 100644