Skip to content

Commit 0392584

Browse files
exafyltdclaude
andauthored
VTID-01225: Fix Cognee memory context bootstrap (#501)
* docs(cognee): Add Cognee integration design for Vitana relationship graph Creates comprehensive design document for integrating Cognee as a stateless entity extraction engine that feeds into VTID-01087 relationship graph tables. Key design decisions (per user corrections): - NO Cognee EBAC: Vitana's ContextLens handles all governance - Dataset per tenant (not per user): Avoids scalability trap - Default graph store: Uses Cognee defaults, persistence in Supabase - Cognee outputs are advisory: Vitana writes are governed/auditable Architecture: - Cognee Extractor Service: Python Cloud Run, stateless extraction - Gateway endpoint: POST /api/v1/relationships/from-cognee - ORB Live integration: Fire-and-forget transcript processing - Full OASIS monitoring and audit trail Includes: - Entity type mapping (Cognee → Vitana node_type) - Relationship type mapping (Cognee → Vitana relationship_type) - Signal extraction for matchmaking - Deployment configs (Cloud Run, Docker) - Security considerations and rollback plan https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * feat(cognee): VTID-01225 Cognee Entity Extraction Integration Implements Cognee as a stateless entity extraction engine for ORB voice transcripts, outputting normalized entities/relationships to VTID-01087 relationship graph tables under full ContextLens governance. Key Design Decisions (per user corrections): - NO Cognee EBAC: Vitana's ContextLens handles all governance - Dataset per tenant (not per user): Avoids scalability trap - Default graph store: Uses Cognee defaults, persistence in Supabase - Cognee outputs are advisory: Vitana writes are governed/auditable Components Created: 1. Cognee Extractor Service (Python Cloud Run) - services/agents/cognee-extractor/main.py - FastAPI service with /extract and /health endpoints - Entity type mapping (Cognee -> Vitana node_type) - Relationship type mapping (Cognee -> Vitana relationship_type) - Signal extraction for matchmaking 2. Gateway Integration - services/gateway/src/services/cognee-extractor-client.ts - HTTP client with retry logic and OASIS events - POST /api/v1/relationships/from-cognee endpoint - Full validation and RLS enforcement 3. ORB Live Integration - Fire-and-forget extraction on session finalize - Integrated in both /end-session and /session/finalize 4. Database Migration - supabase/migrations/20260201000000_vtid_01225_cognee_extractor.sql - VTID-01225 registered in vtid_ledger - cognee_extraction_requests table for tracking - cognee_track_extraction RPC function 5. Deployment - Cloud Run service.yaml configuration - Dockerfile for container build - Environment configuration OASIS Events: - cognee.extraction.started - cognee.extraction.completed - cognee.extraction.timeout - cognee.extraction.persisted - cognee.extraction.error Dependencies: - VTID-01087 (Relationship Graph Memory) - VTID-01224 (ORB Live API Intelligence Stack) https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(cognee): Add manifest.json and package.json for CICD compliance VTID-01225: Adds required manifest.json and package.json files for the cognee-extractor service to pass CICDL-CORE-LINT-SERVICES validation. - manifest.json: Service metadata, provider policy, constraints, OASIS events - package.json: npm-style scripts for dev/start/test https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(cognee): Fix TypeScript errors in orb-live.ts Cognee integration - Change turn.content to turn.text (OrbTranscriptTurn uses 'text' property) - Remove references to transcript.tenant_id/user_id (not in OrbSessionTranscript) - Use dev sandbox defaults directly for tenant/user context https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(types): Add missing CicdEventType entries for CI compliance Adds missing event types to CicdEventType union: - VTID-01225 Cognee extraction events (cognee.extraction.*) - Pre-existing autopilot recommendation events - Pre-existing dev fallback events These were causing TypeScript compilation failures in CI. https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(cognee): Use Vertex AI (Gemini) instead of OpenAI for Cognee Extractor VTID-01225: Align Cognee Extractor with Vitana's existing LLM stack. Changes: - Switch from OpenAI to Google/Gemini as the LLM provider - Use ADC (Application Default Credentials) on Cloud Run - no API key needed - Configure Vertex AI project/location matching gateway setup - Add google-cloud-aiplatform dependency for Vertex AI support - Update manifest.json to reflect correct provider policy The ORB Live API continues using Gemini 2.0 Live API unchanged. Cognee Extractor now uses gemini-2.0-flash for entity extraction to maintain a unified Vertex AI stack across all services. https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(cognee): Lowercase GCP labels in service.yaml for Cloud Run compliance GCP labels must be lowercase. Changed: - vtid: VTID-01225 → vtid-01225 - vt_layer: AICOR → aicor - vt_module: COGNEE → cognee https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(cognee): Remove reserved PORT env var from service.yaml Cloud Run automatically sets PORT - removed from env config. https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(cognee): Add BETA launch stage for readiness probe support https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(cognee): Use Artifact Registry image path instead of gcr.io https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * feat(cognee): Add cognee-extractor to canonical deploy script VTID-01225: Integrated cognee-extractor into Vitana's deployment governance. Changes: - Added SERVICE_MAPPINGS entry for cognee-extractor - Added cognee-extractor specific deployment config: - Internal-only ingress (--no-allow-unauthenticated) - Vertex AI environment variables - Auto-grants gateway invoke permissions - Updated service.yaml with Artifact Registry image path Compliant with SYS-RULE-DEPLOY-L1. https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(cognee): Remove failing IAM binding from deploy script Internal ingress services can communicate without explicit IAM binding. https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(cognee): Use correct Cognee config API and Gemini API key VTID-01225: Fixed Cognee LLM configuration. Changes: - Use cognee.config.set_llm_provider/model/api_key methods (not dict) - Use 'gemini' provider with 'gemini/gemini-2.0-flash' model format - Bind GOOGLE_GEMINI_API_KEY secret (same key as gateway ORB) - Fix deploy script health check for internal-only services Reference: https://docs.cognee.ai/setup-configuration/llm-providers https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * feat(cognee): Add COGNEE_EXTRACTOR_URL to gateway deploy config VTID-01225: Gateway needs the Cognee Extractor URL to enable entity extraction from ORB voice transcripts. https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * feat(cognee): Add Cognee extraction to Gemini Live sessions VTID-01225: Extended Cognee integration to support command-hub ORB. Changes: - Added transcriptTurns array to GeminiLiveSession interface - Accumulate input/output transcriptions during live streaming - Trigger Cognee extraction on /live/session/stop endpoint - Use session identity for tenant/user context when available Now supports both: - ORB sessions (/end-session, /session/finalize) - Gemini Live sessions (/live/session/stop) https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * feat(orb): Enable audio transcription in Gemini Live API VTID-01225: Added input_audio_transcription and output_audio_transcription to the Gemini Live API setup config. This enables: - Transcripts to display in the UI chat window - Cognee extraction to receive transcript data https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(orb): Extract .text from Gemini transcription objects VTID-01225: Fix transcription parsing for Gemini Live API The Gemini Live API returns transcriptions as objects with a .text property, not as direct strings. This fix: - Extracts .text from input_transcription and output_transcription objects - Handles both object format and direct string format for backward compat - Adds debug logging to trace raw transcription objects https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(orb): Move transcription config to setup level VTID-01225: Gemini Live API requires transcription config at setup level, not nested inside generation_config. Moved output_audio_transcription and input_audio_transcription to the correct location. https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(orb): Use correct Gemini model with transcription support VTID-01225: Update model from 'gemini-live-2.5-flash-native-audio' to 'gemini-2.5-flash-native-audio-preview-12-2025' which is documented as supporting input_audio_transcription and output_audio_transcription. Research findings: - The old model name format didn't match documented working examples - Preview model with date suffix has confirmed transcription support - Config placement at setup level (not in generation_config) is correct Sources: - googleapis/python-genai#1279 - googleapis/js-genai#1212 - Vertex AI Live API documentation https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * Revert "fix(orb): Use correct Gemini model with transcription support" This reverts commit 4c073f8. * debug(orb): Add logging for server_content keys to debug transcription VTID-01225: Log the keys present in Gemini's server_content responses to understand the actual message structure being returned. https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * feat(orb): Add parallel Web Speech API for transcript display VTID-01225: Since Gemini Live API doesn't return transcription data, use browser's Web Speech API in parallel to display user's spoken words in the chat UI. Implementation: - Add geminiLiveTranscriber state variable - Add geminiLiveStartTranscriber() - starts Web Speech API for display-only - Add geminiLiveStopTranscriber() - cleanup on session stop - Transcripts displayed in UI but NOT sent to backend (Gemini has audio) - Auto-restart on recognition end while session is active This gives users immediate feedback of their spoken words while maintaining the voice-to-voice experience with Gemini. https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * ci: Add VTID-01225 to Command Hub ownership allowlist VTID-01225: Cognee Entity Extraction Integration requires frontend changes for parallel Web Speech API transcription display. Added to ALLOWED_VTID_PATTERN: - VTID-01225 - cognee-vitana-integration branch pattern https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(cognee): Use memory_items for Cognee extraction instead of transcriptTurns VTID-01225: Since Gemini Live API doesn't return transcription data, fetch conversation history from memory_items table instead. Changes: - Add fetchRecentConversationForCognee() in orb-memory-bridge.ts - Update /live/session/stop to query memory_items by time range - Build transcript from stored user/assistant messages - Send to Cognee extractor for entity extraction This ensures Cognee receives conversation data regardless of whether Gemini returns transcription. https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(cognee): Fix TypeScript errors - use user_id instead of id VTID-01225: SupabaseIdentity uses user_id not id, and tenant_id can be null. Added null check for tenant_id. https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(cognee): Write Gemini Live transcriptions to memory_items for Cognee extraction The Gemini Live session was accumulating transcriptions in-memory (transcriptTurns) but never persisting them to the memory_items table. This meant fetchRecentConversationForCognee always returned empty, so Cognee extraction was never triggered. Changes: - Add outputTranscriptBuffer to accumulate transcription chunks during a turn - Write full assistant transcript to memory_items on turnComplete event - Write user input transcription immediately (rare - Gemini native audio doesn't usually provide this) - Fix TypeScript errors by creating explicit MemoryIdentity objects https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(cognee): Add DEV_IDENTITY fallback and debug logging for memory writes The Gemini Live session had no identity attached (unauthenticated), causing memory writes to be silently skipped. Added: - DEV_IDENTITY fallback for dev-sandbox mode (like other ORB endpoints) - Debug logging to track identity resolution - Logging when memory writes are skipped due to missing identity https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(cognee): Allow unauthenticated access to cognee-extractor (internal-only) The cognee-extractor was deployed with --no-allow-unauthenticated, but the gateway's cognee-extractor-client doesn't pass auth tokens. This caused 404 errors when gateway tried to call /extract. Since cognee-extractor already has --ingress internal (only Cloud Run services in the same project can reach it), network-level security is sufficient. Changed to --allow-unauthenticated to allow gateway to call without auth tokens. https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(cognee): Add CPU/memory boost for cognee-extractor startup Cognee initialization takes ~25-30 seconds due to heavy imports and database setup. The default Cloud Run startup probe was timing out. Added: - 1 CPU (up from default 0.25) - 1GB memory (up from default 256MB) - --cpu-boost for faster cold starts - 300s timeout for long extraction operations https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * fix(cognee): Remove cpu/memory flags causing deploy conflict * fix(cognee): Add DEV_IDENTITY fallback for memory RECALL in dev-sandbox The critical bug: Memory writes had DEV_IDENTITY fallback but memory reads at session start did NOT. For unauthenticated dev-sandbox sessions, context bootstrap was skipped entirely (line 4992 only ran for authenticated sessions). This fix: - Creates devSandboxIdentity with full SupabaseIdentity shape for dev-sandbox - Uses effective identity for buildBootstrapContextPack() calls - Stores effective identity in liveSession for consistent memory writes - Adds logging to indicate when DEV_IDENTITY fallback is being used Now when a user starts an ORB session in dev-sandbox mode: 1. Memory is read using DEV_IDENTITY (previously skipped) 2. Context is bootstrapped and injected into system prompt 3. Memory is written using DEV_IDENTITY (already worked) 4. ORB should now REMEMBER information across sessions https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh * feat(cognee): Add context bootstrap test endpoint for Voice LAB VTID-01225: Adds GET /api/v1/orb/debug/context-bootstrap endpoint that exercises the exact same buildBootstrapContextPack() code path used by Gemini Live sessions. This allows testing memory recall without starting a full ORB session: - Accepts optional user_id, tenant_id, role query params - Defaults to DEV_IDENTITY for dev-sandbox testing - Returns detailed bootstrap results including: - latency_ms, memory_hits, knowledge_hits, context_chars - Memory items with category, content preview, relevance scores - Full context instruction that would be injected into system prompt Useful for Voice LAB testing screens and debugging memory retrieval. https://claude.ai/code/session_01FGZx1ZrwRtx5JN6m4rRMqh --------- Co-authored-by: Claude <[email protected]>
1 parent 7896bed commit 0392584

9 files changed

Lines changed: 599 additions & 57 deletions

File tree

‎scripts/ci/command-hub-ownership-guard.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ const PROTECTED_PATH = 'services/gateway/src/frontend/command-hub/';
138138
// VTID-01218B: Voice LAB Experiments Panel (runtime controls, kill switch, experiment selector)
139139
// VTID-01218E: Voice LAB Navigation in Command Hub (sub-tab routing + session browser)
140140
// Branch pattern: fix-fragmentation-integration (for claude/fix-fragmentation-integration-* branches)
141-
const ALLOWED_VTID_PATTERN = /DEV-COMHU-\d+|VTID-0302|VTID-0539|VTID-0541|VTID-0542|VTID-0600|VTID-0601|VTID-01001|VTID-01002|VTID-01003|VTID-01005|VTID-01006|VTID-01009|VTID-01010|VTID-01012|VTID-01013|VTID-01014|VTID-01015|VTID-01016|VTID-01017|VTID-01019|VTID-01021|VTID-01022|VTID-01025|VTID-01027|VTID-01028|VTID-01030|VTID-01034|VTID-0135|VTID-01037|VTID-01038|VTID-01039|VTID-01041|VTID-01042|VTID-01043|VTID-01044|VTID-01045|VTID-01049|VTID-01052|VTID-01055|VTID-01064|VTID-01066|VTID-01067|VTID-01069|VTID-01079|VTID-01086|VTID-01109|VTID-01111|VTID-01122|VTID-01150|VTID-01155|VTID-01156|VTID-01154|VTID-01168|VTID-01171|VTID-01172|VTID-01173|VTID-01174|VTID-01180|VTID-01181|VTID-01186|VTID-01188|VTID-01189|VTID-01194|VTID-01195|VTID-01196|VTID-01208|VTID-01209|VTID-01210|VTID-01211|VTID-01214|VTID-01216|VTID-01218A|VTID-01218B|VTID-01218E|VTID-01221|SPEC-01|global-vtid-allocator|vtid-ledger-visibility|add-conversation-summary|editable-scheduled-card-title|unified-language-selector|fix-stt-abort-error|fix-tts-feedback|compact-cards-date-filter|gateway-me-context-api|delete-scheduled-tasks|fix-ghost-cards|security-audit-review|fix-vtid-board-mapping|orb-conversation-stream|orb-presence-layer|auto-growing-chatbox|memory-garden-ui-depth|debug-orb-memory|debug-command-hub-vtids|remove-deleted-task|runner-execution-bridge|gemini-live-multimodal-tts|remove-legacy-tasks-fetch|global-top-navigation|github-approvals-feed|approval-auto-deploy|wire-profile-modal-api|dev-users-access-toggle|agents-ui-orchestrator-apis|agents-control-plane-pipelines|autopilot-event-loop|add-arming-panel|replace-dev-identity-jwt|fix-validation|unified-spec-generation|infinite-scroll-list|fix-vtid-ledger-layout|fix-login-ui-update|command-hub-admin-screens|fetch-user-profile|document-agent-setup|task-pipeline-status-view|fix-live-ticker-formatting|fix-page-scrolling|document-operator-features|fix-duplicate-formatRelativeTime|unified-conversation-intelligence|sync-orb-autopilot|fix-fragmentation-integration/i;
141+
// VTID-01225: Cognee Entity Extraction Integration (ORB transcript display + Cognee memory)
142+
// Branch pattern: cognee-vitana-integration (for claude/cognee-vitana-integration-* branches)
143+
const ALLOWED_VTID_PATTERN = /DEV-COMHU-\d+|VTID-0302|VTID-0539|VTID-0541|VTID-0542|VTID-0600|VTID-0601|VTID-01001|VTID-01002|VTID-01003|VTID-01005|VTID-01006|VTID-01009|VTID-01010|VTID-01012|VTID-01013|VTID-01014|VTID-01015|VTID-01016|VTID-01017|VTID-01019|VTID-01021|VTID-01022|VTID-01025|VTID-01027|VTID-01028|VTID-01030|VTID-01034|VTID-0135|VTID-01037|VTID-01038|VTID-01039|VTID-01041|VTID-01042|VTID-01043|VTID-01044|VTID-01045|VTID-01049|VTID-01052|VTID-01055|VTID-01064|VTID-01066|VTID-01067|VTID-01069|VTID-01079|VTID-01086|VTID-01109|VTID-01111|VTID-01122|VTID-01150|VTID-01155|VTID-01156|VTID-01154|VTID-01168|VTID-01171|VTID-01172|VTID-01173|VTID-01174|VTID-01180|VTID-01181|VTID-01186|VTID-01188|VTID-01189|VTID-01194|VTID-01195|VTID-01196|VTID-01208|VTID-01209|VTID-01210|VTID-01211|VTID-01214|VTID-01216|VTID-01218A|VTID-01218B|VTID-01218E|VTID-01221|VTID-01225|SPEC-01|global-vtid-allocator|vtid-ledger-visibility|add-conversation-summary|editable-scheduled-card-title|unified-language-selector|fix-stt-abort-error|fix-tts-feedback|compact-cards-date-filter|gateway-me-context-api|delete-scheduled-tasks|fix-ghost-cards|security-audit-review|fix-vtid-board-mapping|orb-conversation-stream|orb-presence-layer|auto-growing-chatbox|memory-garden-ui-depth|debug-orb-memory|debug-command-hub-vtids|remove-deleted-task|runner-execution-bridge|gemini-live-multimodal-tts|remove-legacy-tasks-fetch|global-top-navigation|github-approvals-feed|approval-auto-deploy|wire-profile-modal-api|dev-users-access-toggle|agents-ui-orchestrator-apis|agents-control-plane-pipelines|autopilot-event-loop|add-arming-panel|replace-dev-identity-jwt|fix-validation|unified-spec-generation|infinite-scroll-list|fix-vtid-ledger-layout|fix-login-ui-update|command-hub-admin-screens|fetch-user-profile|document-agent-setup|task-pipeline-status-view|fix-live-ticker-formatting|fix-page-scrolling|document-operator-features|fix-duplicate-formatRelativeTime|unified-conversation-intelligence|sync-orb-autopilot|fix-fragmentation-integration|cognee-vitana-integration/i;
142144

143145
function getChangedFiles() {
144146
try {

‎scripts/deploy/deploy-service.sh‎

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ NC="\033[0m"
2323
# =============================================================================
2424
declare -A SERVICE_MAPPINGS=(
2525
["vitana-verification-engine"]="services/agents/vitana-orchestrator:/health:vitana-verification-engine"
26+
["cognee-extractor"]="services/agents/cognee-extractor:/health:cognee-extractor"
2627
)
2728

2829
# =============================================================================
@@ -135,13 +136,15 @@ echo -e "${YELLOW}Deploying ${CLOUD_RUN_SERVICE} to Cloud Run...${NC}"
135136
# NOTE: --set-secrets REPLACES all secrets, so we must include ALL required secrets here
136137
if [ "$CLOUD_RUN_SERVICE" = "gateway" ]; then
137138
echo -e "${YELLOW}VTID-01125: Binding secrets for gateway service...${NC}"
139+
# VTID-01225: Add Cognee Extractor URL for entity extraction
140+
COGNEE_URL="https://cognee-extractor-q74ibpv6ia-uc.a.run.app"
138141
gcloud run deploy "$CLOUD_RUN_SERVICE" \
139142
--project "$PROJECT" \
140143
--region "$REGION" \
141144
--source "$SOURCE_PATH" \
142145
--platform managed \
143146
--allow-unauthenticated \
144-
--set-env-vars "ENVIRONMENT=${ENVIRONMENT},AUTOPILOT_LOOP_ENABLED=true,GOOGLE_CLOUD_PROJECT=lovable-vitana-vers1" \
147+
--set-env-vars "ENVIRONMENT=${ENVIRONMENT},AUTOPILOT_LOOP_ENABLED=true,GOOGLE_CLOUD_PROJECT=lovable-vitana-vers1,COGNEE_EXTRACTOR_URL=${COGNEE_URL}" \
145148
--set-secrets "GOOGLE_GEMINI_API_KEY=GOOGLE_GEMINI_API_KEY:latest,SUPABASE_URL=SUPABASE_URL:latest,SUPABASE_SERVICE_ROLE=SUPABASE_SERVICE_ROLE:latest,SUPABASE_ANON_KEY=SUPABASE_ANON_KEY:latest,SUPABASE_JWT_SECRET=SUPABASE_JWT_SECRET:latest,GITHUB_TOKEN=GITHUB_TOKEN:latest,GH_TOKEN=GITHUB_TOKEN:latest,GITHUB_SAFE_MERGE_TOKEN=GITHUB_TOKEN:latest,DEV_AUTH_SECRET=DEV_AUTH_SECRET:latest,DEV_TEST_USER_EMAIL=DEV_TEST_USER_EMAIL:latest,DEV_TEST_USER_PASSWORD=DEV_TEST_USER_PASSWORD:latest,DEV_JWT_SECRET=DEV_JWT_SECRET:latest,PERPLEXITY_API_KEY=PERPLEXITY_API_KEY:latest" \
146149
--quiet
147150
elif [ "$CLOUD_RUN_SERVICE" = "worker-runner" ]; then
@@ -160,6 +163,24 @@ elif [ "$CLOUD_RUN_SERVICE" = "worker-runner" ]; then
160163
--set-env-vars "ENVIRONMENT=${ENVIRONMENT},GATEWAY_URL=${GATEWAY_URL_VALUE}" \
161164
--set-secrets "SUPABASE_URL=SUPABASE_URL:latest,SUPABASE_SERVICE_ROLE=SUPABASE_SERVICE_ROLE:latest" \
162165
--quiet
166+
elif [ "$CLOUD_RUN_SERVICE" = "cognee-extractor" ]; then
167+
# VTID-01225: Cognee Extractor - uses Gemini API for entity extraction
168+
# Internal-only ingress with allow-unauthenticated (network security via internal ingress)
169+
# Cognee initialization takes ~25-30 seconds, cpu-boost helps with cold starts
170+
echo -e "${YELLOW}VTID-01225: Deploying Cognee Extractor with Gemini API config...${NC}"
171+
gcloud run deploy "$CLOUD_RUN_SERVICE" \
172+
--project "$PROJECT" \
173+
--region "$REGION" \
174+
--source "$SOURCE_PATH" \
175+
--platform managed \
176+
--allow-unauthenticated \
177+
--ingress internal \
178+
--cpu-boost \
179+
--set-env-vars "ENVIRONMENT=${ENVIRONMENT},LLM_PROVIDER=gemini,LLM_MODEL=gemini/gemini-2.0-flash,GOOGLE_CLOUD_PROJECT=${PROJECT}" \
180+
--set-secrets "GOOGLE_GEMINI_API_KEY=GOOGLE_GEMINI_API_KEY:latest" \
181+
--quiet
182+
# Note: Internal ingress provides network-level security - only Cloud Run services in same project can call
183+
echo -e "${GREEN}Cognee Extractor deployed with internal-only ingress.${NC}"
163184
else
164185
gcloud run deploy "$CLOUD_RUN_SERVICE" \
165186
--project "$PROJECT" \
@@ -188,20 +209,44 @@ echo -e "${GREEN}Service URL: ${SERVICE_URL}${NC}"
188209
# =============================================================================
189210
# STEP 3 — Post-deploy health check
190211
# =============================================================================
191-
echo -e "${YELLOW}Running post-deploy health check: ${SERVICE_URL}${HEALTH_PATH}${NC}"
192212

193-
# Wait a moment for service to stabilize
194-
sleep 5
213+
# Check if service has internal-only ingress (can't curl from outside)
214+
INGRESS=$(gcloud run services describe "$CLOUD_RUN_SERVICE" \
215+
--project "$PROJECT" \
216+
--region "$REGION" \
217+
--format='value(spec.template.metadata.annotations."run.googleapis.com/ingress")' 2>/dev/null || echo "all")
195218

196-
if curl -fsS "${SERVICE_URL}${HEALTH_PATH}" -o /tmp/health_response.json; then
197-
echo -e "${GREEN}Health check PASSED${NC}"
198-
echo -e "${CYAN}Response:${NC}"
199-
cat /tmp/health_response.json | jq '.' 2>/dev/null || cat /tmp/health_response.json
200-
echo ""
219+
if [ "$INGRESS" = "internal" ] || [ "$INGRESS" = "internal-and-cloud-load-balancing" ]; then
220+
echo -e "${YELLOW}Service has internal-only ingress - checking Cloud Run status instead...${NC}"
221+
# For internal services, verify via Cloud Run API that latest revision is serving
222+
SERVING_STATUS=$(gcloud run services describe "$CLOUD_RUN_SERVICE" \
223+
--project "$PROJECT" \
224+
--region "$REGION" \
225+
--format='value(status.conditions[0].status)' 2>/dev/null || echo "Unknown")
226+
227+
if [ "$SERVING_STATUS" = "True" ]; then
228+
echo -e "${GREEN}Health check PASSED (internal service is serving)${NC}"
229+
else
230+
echo -e "${RED}Health check FAILED: Service status is ${SERVING_STATUS}${NC}"
231+
echo -e "${RED}Check Cloud Run logs: gcloud run services logs read ${CLOUD_RUN_SERVICE} --region=${REGION}${NC}"
232+
exit 1
233+
fi
201234
else
202-
echo -e "${RED}Health check FAILED: ${SERVICE_URL}${HEALTH_PATH}${NC}"
203-
echo -e "${RED}Deployment may have issues. Check Cloud Run logs.${NC}"
204-
exit 1
235+
echo -e "${YELLOW}Running post-deploy health check: ${SERVICE_URL}${HEALTH_PATH}${NC}"
236+
237+
# Wait a moment for service to stabilize
238+
sleep 5
239+
240+
if curl -fsS "${SERVICE_URL}${HEALTH_PATH}" -o /tmp/health_response.json; then
241+
echo -e "${GREEN}Health check PASSED${NC}"
242+
echo -e "${CYAN}Response:${NC}"
243+
cat /tmp/health_response.json | jq '.' 2>/dev/null || cat /tmp/health_response.json
244+
echo ""
245+
else
246+
echo -e "${RED}Health check FAILED: ${SERVICE_URL}${HEALTH_PATH}${NC}"
247+
echo -e "${RED}Deployment may have issues. Check Cloud Run logs.${NC}"
248+
exit 1
249+
fi
205250
fi
206251

207252
# =============================================================================

‎services/agents/cognee-extractor/main.py‎

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,16 @@
3535
# Configuration
3636
# =============================================================================
3737

38-
# LLM Configuration (uses Cognee defaults if not set)
39-
LLM_API_KEY = os.getenv('LLM_API_KEY')
40-
LLM_PROVIDER = os.getenv('LLM_PROVIDER', 'openai')
41-
LLM_MODEL = os.getenv('LLM_MODEL', 'gpt-4o-mini')
38+
# LLM Configuration - Uses Gemini API (same key as ORB)
39+
# Cognee requires API key authentication for Gemini
40+
LLM_PROVIDER = os.getenv('LLM_PROVIDER', 'gemini')
41+
LLM_MODEL = os.getenv('LLM_MODEL', 'gemini/gemini-2.0-flash')
42+
LLM_API_KEY = os.getenv('GOOGLE_GEMINI_API_KEY') or os.getenv('LLM_API_KEY')
43+
LLM_ENDPOINT = os.getenv('LLM_ENDPOINT', 'https://generativelanguage.googleapis.com/')
44+
45+
# Google Cloud project (for reference)
46+
GCP_PROJECT = os.getenv('GOOGLE_CLOUD_PROJECT') or os.getenv('GCP_PROJECT') or 'lovable-vitana-vers1'
47+
GCP_LOCATION = os.getenv('VERTEX_LOCATION', 'us-central1')
4248

4349
# Service Configuration
4450
SERVICE_NAME = 'cognee-extractor'
@@ -376,17 +382,19 @@ async def lifespan(app: FastAPI):
376382
"""Application lifespan handler."""
377383
logger.info(f'[{VTID}] Starting {SERVICE_NAME}...')
378384

379-
# Configure Cognee LLM if API key provided
380-
if LLM_API_KEY:
381-
try:
382-
cognee.config.set_llm_config({
383-
'provider': LLM_PROVIDER,
384-
'model': LLM_MODEL,
385-
'api_key': LLM_API_KEY
386-
})
385+
# Configure Cognee LLM with Gemini API
386+
# Uses same GOOGLE_GEMINI_API_KEY as gateway ORB
387+
try:
388+
if LLM_API_KEY:
389+
cognee.config.set_llm_provider(LLM_PROVIDER)
390+
cognee.config.set_llm_model(LLM_MODEL)
391+
cognee.config.set_llm_api_key(LLM_API_KEY)
392+
cognee.config.set_llm_endpoint(LLM_ENDPOINT)
387393
logger.info(f'[{VTID}] Configured Cognee with {LLM_PROVIDER}/{LLM_MODEL}')
388-
except Exception as e:
389-
logger.warning(f'[{VTID}] Failed to configure Cognee LLM: {e}')
394+
else:
395+
logger.warning(f'[{VTID}] No LLM_API_KEY provided - Cognee will use defaults')
396+
except Exception as e:
397+
logger.warning(f'[{VTID}] Failed to configure Cognee LLM: {e}')
390398

391399
logger.info(f'[{VTID}] {SERVICE_NAME} ready')
392400
yield

‎services/agents/cognee-extractor/manifest.json‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
"description": "Cognee Entity Extraction Service - Stateless entity extraction engine for ORB voice transcripts. Outputs normalized entities/relationships for VTID-01087 relationship graph.",
88
"provider_policy": {
99
"llm": {
10-
"provider": "openai",
11-
"model": "gpt-4o-mini"
10+
"provider": "google",
11+
"model": "gemini-2.0-flash",
12+
"note": "Uses Vertex AI with ADC (Application Default Credentials) - matches Vitana stack"
1213
},
1314
"graph_store": {
1415
"provider": "cognee_default",
@@ -20,12 +21,17 @@
2021
}
2122
},
2223
"required_env": [
23-
"LLM_API_KEY"
24+
"GOOGLE_CLOUD_PROJECT"
2425
],
2526
"optional_env": [
27+
"VERTEX_LOCATION",
2628
"LLM_PROVIDER",
2729
"LLM_MODEL"
2830
],
31+
"not_required": [
32+
"LLM_API_KEY",
33+
"OPENAI_API_KEY"
34+
],
2935
"features": [
3036
"cognee_entity_extraction",
3137
"relationship_normalization",

‎services/agents/cognee-extractor/requirements.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ pydantic>=2.0.0
99
# Cognee AI Memory Engine
1010
cognee>=0.5.1
1111

12+
# Google Cloud / Vertex AI (Gemini) - matches Vitana stack
13+
# Uses ADC (Application Default Credentials) on Cloud Run
14+
google-cloud-aiplatform>=1.38.0
15+
google-generativeai>=0.3.0
16+
1217
# HTTP client for health checks
1318
httpx>=0.26.0
1419

‎services/agents/cognee-extractor/service.yaml‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ kind: Service
1111
metadata:
1212
name: cognee-extractor
1313
labels:
14-
vtid: VTID-01225
15-
vt_layer: AICOR
16-
vt_module: COGNEE
14+
vtid: vtid-01225
15+
vt_layer: aicor
16+
vt_module: cognee
1717
cloud.googleapis.com/location: us-central1
1818
annotations:
1919
run.googleapis.com/description: "VTID-01225: Stateless entity extraction engine for ORB voice transcripts"
2020
run.googleapis.com/ingress: internal
21+
run.googleapis.com/launch-stage: BETA
2122
spec:
2223
template:
2324
metadata:
@@ -36,7 +37,7 @@ spec:
3637
# run.googleapis.com/vpc-access-connector: projects/lovable-vitana-vers1/locations/us-central1/connectors/vitana-vpc-connector
3738

3839
labels:
39-
vtid: VTID-01225
40+
vtid: vtid-01225
4041
spec:
4142
# Container concurrency - how many requests per instance
4243
containerConcurrency: 10
@@ -48,7 +49,7 @@ spec:
4849
serviceAccountName: [email protected]
4950

5051
containers:
51-
- image: gcr.io/lovable-vitana-vers1/cognee-extractor:latest
52+
- image: us-central1-docker.pkg.dev/lovable-vitana-vers1/vitana-services/cognee-extractor:latest
5253
ports:
5354
- containerPort: 8080
5455
name: http1
@@ -64,20 +65,18 @@ spec:
6465

6566
# Environment variables
6667
env:
67-
# LLM Configuration
68+
# LLM Configuration - Uses Vertex AI (Gemini) to match Vitana stack
69+
# Auth via ADC (Application Default Credentials) - no API key needed
6870
- name: LLM_PROVIDER
69-
value: "openai"
71+
value: "google"
7072
- name: LLM_MODEL
71-
value: "gpt-4o-mini"
72-
- name: LLM_API_KEY
73-
valueFrom:
74-
secretKeyRef:
75-
name: cognee-secrets
76-
key: llm-api-key
73+
value: "gemini-2.0-flash"
74+
- name: GOOGLE_CLOUD_PROJECT
75+
value: "lovable-vitana-vers1"
76+
- name: VERTEX_LOCATION
77+
value: "us-central1"
7778

7879
# Service configuration
79-
- name: PORT
80-
value: "8080"
8180
- name: ENV
8281
value: "production"
8382

0 commit comments

Comments
 (0)