feat(production): sync all modified production files to git

Includes updates across gateway, router, node-worker, memory-service,
aurora-service, swapper, sofiia-console UI and node2 infrastructure:

- gateway-bot: Dockerfile, http_api.py, druid/aistalk prompts, doc_service
- services/router: main.py, router-config.yml, fabric_metrics, memory_retrieval,
  offload_client, prompt_builder
- services/node-worker: worker.py, main.py, config.py, fabric_metrics
- services/memory-service: Dockerfile, database.py, main.py, requirements
- services/aurora-service: main.py (+399), kling.py, quality_report.py
- services/swapper-service: main.py, swapper_config_node2.yaml
- services/sofiia-console: static/index.html (console UI update)
- config: agent_registry, crewai_agents/teams, router_agents
- ops/fabric_preflight.sh: updated preflight checks
- router-config.yml, docker-compose.node2.yml: infra updates
- docs: NODA1-AGENT-ARCHITECTURE, fabric_contract updated

Made-with: Cursor
This commit is contained in:
Apple
2026-03-03 07:13:29 -08:00
parent 9aac835882
commit e9dedffa48
35 changed files with 3317 additions and 805 deletions

View File

@@ -9,6 +9,7 @@ set -euo pipefail
NODA_NCS="${1:-http://127.0.0.1:8099}"
ROUTER_URL="${2:-http://127.0.0.1:9102}"
MEMORY_URL="${3:-http://127.0.0.1:8000}"
RED='\033[0;31m'
GREEN='\033[0;32m'
@@ -64,10 +65,42 @@ print(' '.join(parts) if parts else '(none — P3.5 not deployed?)')
vision_count=$(echo "$raw" | python3 -c "import json,sys;print(sum(1 for m in json.load(sys.stdin).get('served_models',[]) if m.get('type')=='vision'))" 2>/dev/null)
[ "$vision_count" -gt 0 ] && pass "vision models: $vision_count" || warn "no vision models served"
# Phase 1: explicit STT/TTS capability check
local stt_cap tts_cap stt_provider tts_provider
stt_cap=$(echo "$raw" | python3 -c "import json,sys;print(json.load(sys.stdin).get('capabilities',{}).get('stt','?'))" 2>/dev/null)
tts_cap=$(echo "$raw" | python3 -c "import json,sys;print(json.load(sys.stdin).get('capabilities',{}).get('tts','?'))" 2>/dev/null)
stt_provider=$(echo "$raw" | python3 -c "import json,sys;print(json.load(sys.stdin).get('capabilities',{}).get('providers',{}).get('stt','?'))" 2>/dev/null)
tts_provider=$(echo "$raw" | python3 -c "import json,sys;print(json.load(sys.stdin).get('capabilities',{}).get('providers',{}).get('tts','?'))" 2>/dev/null)
[ "$stt_cap" = "True" ] || [ "$stt_cap" = "true" ] \
&& pass "stt=true provider=$stt_provider" \
|| warn "stt=false (provider=$stt_provider) — STT not available on this node"
[ "$tts_cap" = "True" ] || [ "$tts_cap" = "true" ] \
&& pass "tts=true provider=$tts_provider" \
|| warn "tts=false (provider=$tts_provider) — TTS not available on this node"
NCS_RAW="$raw"
NCS_NODE_ID="$node_id"
}
# ── Memory Service health check ────────────────────────────────────────────────
check_memory_service() {
local label="$1" url="$2"
echo "── $label ($url/health) ──"
local health
health=$(curl -sf "$url/health" 2>/dev/null) || { warn "Memory Service unreachable at $url (STT/TTS may fail)"; return; }
local status
status=$(echo "$health" | python3 -c "import json,sys;print(json.load(sys.stdin).get('status','?'))" 2>/dev/null || echo "ok")
pass "memory-service health=$status"
local voice_status
voice_status=$(curl -sf "$url/voice/status" 2>/dev/null) || { warn "voice/status unreachable"; return; }
local tts_engine stt_engine
tts_engine=$(echo "$voice_status" | python3 -c "import json,sys;print(json.load(sys.stdin).get('tts_engine','?'))" 2>/dev/null)
stt_engine=$(echo "$voice_status" | python3 -c "import json,sys;print(json.load(sys.stdin).get('stt_engine','?'))" 2>/dev/null)
pass "voice: tts=$tts_engine stt=$stt_engine"
}
# ── Router check ──────────────────────────────────────────────────────────────
check_router() {
@@ -163,6 +196,91 @@ else:
info "Snapshot: $snap_file"
}
# ── Ollama model availability check ──────────────────────────────────────────
# Voice routing policy depends on specific models; 502 from BFF = model absent.
# This check probes /api/tags (Ollama REST) to list installed models and
# emits NCS-compatible "installed=false" warnings so Router can exclude them.
OLLAMA_URL="${4:-http://127.0.0.1:11434}"
# Voice policy: models required/preferred for voice_fast_uk / voice_quality_uk
VOICE_REQUIRED_MODELS="gemma3:latest"
VOICE_PREFERRED_MODELS="qwen3.5:35b-a3b qwen3:14b"
VOICE_EXCLUDED_MODELS="glm-4.7-flash:32k glm-4.7-flash"
check_ollama_voice_models() {
local ollama_url="${1:-$OLLAMA_URL}"
echo "── Ollama voice model availability ($ollama_url) ──"
local tags_raw
tags_raw=$(curl -sf "${ollama_url}/api/tags" 2>/dev/null) \
|| { warn "Ollama unreachable at ${ollama_url} — model check skipped"; return; }
local installed_names
installed_names=$(echo "$tags_raw" | python3 -c "
import json, sys
data = json.load(sys.stdin)
models = data.get('models', [])
names = [m.get('name','') for m in models]
print(' '.join(names))
" 2>/dev/null || echo "")
info "Ollama installed: $(echo "$installed_names" | tr ' ' '\n' | grep -c . || echo 0) model(s)"
# Check required voice models
for model in $VOICE_REQUIRED_MODELS; do
local short; short="${model%%:*}"
if echo "$installed_names" | tr ' ' '\n' | grep -qi "^${model}$\|^${short}:"; then
pass "voice_required: ${model} = installed"
else
fail "voice_required: ${model} = MISSING — voice_fast_uk will degrade to fallback"
fi
done
# Check preferred voice models (warn not fail)
local prefer_available=0
for model in $VOICE_PREFERRED_MODELS; do
local short; short="${model%%:*}"
if echo "$installed_names" | tr ' ' '\n' | grep -qi "^${model}$\|^${short}:"; then
pass "voice_preferred: ${model} = installed"
prefer_available=$((prefer_available + 1))
else
warn "voice_preferred: ${model} = not installed — will be skipped by router"
fi
done
# Check that excluded models are NOT serving voice
for model in $VOICE_EXCLUDED_MODELS; do
local short; short="${model%%:*}"
if echo "$installed_names" | tr ' ' '\n' | grep -qi "^${model}$\|^${short}:"; then
warn "voice_excluded: ${model} is installed — ensure router excludes from voice profiles"
else
pass "voice_excluded: ${model} = absent (correct)"
fi
done
# qwen3:8b specific check — known 502 source
local qwen3_8b_ok=0
if echo "$installed_names" | tr ' ' '\n' | grep -qi "^qwen3:8b$"; then
# Extra: try a minimal generation to detect "loaded but broken"
local gen_code
gen_code=$(curl -sf -w "%{http_code}" -X POST "${ollama_url}/api/generate" \
-H "Content-Type: application/json" \
-d '{"model":"qwen3:8b","prompt":"ping","stream":false,"options":{"num_predict":1}}' \
-o /dev/null --max-time 15 2>/dev/null || echo "000")
if [ "$gen_code" = "200" ]; then
pass "qwen3:8b = installed and serves (HTTP 200)"
qwen3_8b_ok=1
else
warn "qwen3:8b = installed but generate returned HTTP ${gen_code} — exclude from voice_fast_uk prefer list"
fi
else
warn "qwen3:8b = not installed — mark as unavailable in NCS"
fi
[ $qwen3_8b_ok -eq 0 ] && info "ACTION: remove qwen3:8b from voice_fast_uk.prefer_models until 502 resolved"
}
# ── Main ──────────────────────────────────────────────────────────────────────
echo "╔══════════════════════════════════════╗"
@@ -174,6 +292,26 @@ check_ncs "NCS" "$NODA_NCS"
echo ""
check_router "Router" "$ROUTER_URL"
echo ""
check_memory_service "Memory Service" "$MEMORY_URL"
echo ""
check_ollama_voice_models "$OLLAMA_URL"
echo ""
# ── Voice Canary: live synthesis test (hard-fail on voice failure) ────────────
echo "── Voice Canary (live synthesis) ──────────────────────────────────────"
CANARY_SCRIPT="$(dirname "$0")/scripts/voice_canary.py"
if [ -f "$CANARY_SCRIPT" ] && command -v python3 >/dev/null 2>&1; then
MEMORY_SERVICE_URL="$MEMORY_URL" python3 "$CANARY_SCRIPT" --mode preflight
CANARY_EXIT=$?
if [ $CANARY_EXIT -ne 0 ]; then
ERRORS=$((ERRORS+1))
echo -e " ${RED}FAIL${NC} Voice canary: synthesis test failed (Polina/Ostap not working)"
fi
else
echo " [SKIP] voice_canary.py not found or python3 unavailable"
fi
echo ""
save_and_diff
echo ""
@@ -182,5 +320,5 @@ if [ $ERRORS -gt 0 ]; then
echo -e "${RED}BLOCKED: no changes allowed until all errors resolved${NC}"
exit 1
else
echo -e "${GREEN}Preflight PASSED — changes allowed${NC}"
echo -e "${GREEN}Preflight PASSED — all voice canaries green — changes allowed${NC}"
fi