Cogniverse Study Guide: Package Development¶
Table of Contents¶
- Package Architecture
- Development Workflows
- Dependency Management
- Building Packages
- Testing Strategies
- Versioning and Releases
- Best Practices
Package Architecture¶
UV Workspace Structure¶
cogniverse/
├── pyproject.toml # Workspace root configuration
├── uv.lock # Unified dependency lockfile
├── .venv/ # Shared virtual environment
├── libs/
│ ├── FOUNDATION LAYER (base types and utilities)
│ ├── sdk/ # cogniverse_sdk
│ │ ├── pyproject.toml
│ │ ├── README.md
│ │ └── cogniverse_sdk/
│ │ ├── __init__.py
│ │ ├── document.py # Document types
│ │ └── interfaces/ # Base interfaces and protocols
│ ├── foundation/ # cogniverse_foundation
│ │ ├── pyproject.toml
│ │ ├── README.md
│ │ └── cogniverse_foundation/
│ │ ├── __init__.py
│ │ ├── telemetry/ # Core telemetry
│ │ ├── config/ # Base configuration (incl. config/utils.py)
│ │ ├── caching/ # Cache backends
│ │ ├── dspy/ # DSPy integration helpers
│ │ └── registry/ # Provider entry-point registry
│ │
│ ├── CORE LAYER (business logic and frameworks)
│ ├── evaluation/ # cogniverse_evaluation
│ │ ├── pyproject.toml
│ │ ├── README.md
│ │ └── cogniverse_evaluation/
│ │ ├── __init__.py
│ │ ├── core/ # Evaluation framework
│ │ ├── evaluators/ # Evaluator implementations
│ │ ├── metrics/ # Metric definitions
│ │ ├── analysis/ # Root-cause / plugin analyzers
│ │ ├── data/ # Dataset & storage managers
│ │ ├── plugins/ # Pluggable evaluator extensions
│ │ └── providers/ # Telemetry provider interfaces
│ ├── core/ # cogniverse_core
│ │ ├── pyproject.toml
│ │ ├── README.md
│ │ └── cogniverse_core/
│ │ ├── __init__.py
│ │ ├── agents/ # Agent base classes
│ │ ├── approval/ # Approval workflow interfaces
│ │ ├── backends/ # Backend interfaces
│ │ ├── common/ # Core business logic
│ │ ├── events/ # Event system
│ │ ├── factories/ # Factory classes
│ │ ├── interfaces/ # Core interfaces
│ │ ├── memory/ # Memory management (Mem0, provenance, federation)
│ │ ├── query/ # Query processing
│ │ ├── registries/ # Component registries
│ │ ├── schemas/ # Schema management
│ │ ├── telemetry/ # Telemetry integration
│ │ └── validation/ # Validation logic
│ │
│ ├── IMPLEMENTATION LAYER (specific implementations)
│ ├── telemetry-phoenix/ # cogniverse_telemetry_phoenix
│ │ ├── pyproject.toml
│ │ ├── README.md
│ │ └── cogniverse_telemetry_phoenix/
│ │ ├── __init__.py
│ │ ├── provider.py # PhoenixProvider (telemetry entry point)
│ │ └── evaluation/ # PhoenixEvaluationProvider
│ ├── agents/ # cogniverse_agents (23 A2A agents; see docs/modules/agents.md)
│ │ ├── pyproject.toml
│ │ ├── README.md
│ │ └── cogniverse_agents/
│ │ ├── __init__.py
│ │ ├── orchestrator_agent.py # A2A orchestrator
│ │ ├── search_agent.py # Search agent
│ │ ├── gateway_agent.py # Query classification/routing gateway
│ │ ├── ... (20 more *_agent.py modules)
│ │ ├── approval/ # Approval workflow
│ │ ├── graph/ # Knowledge-graph helpers
│ │ ├── inference/ # Inference logic
│ │ ├── mixins/ # Agent mixins
│ │ ├── optimizer/ # Optimizer agents
│ │ ├── orchestrator/ # Orchestration
│ │ ├── routing/ # Routing strategies
│ │ ├── search/ # Search implementations
│ │ ├── tools/ # Agent tools
│ │ ├── wiki/ # Wiki-backed knowledge tools
│ │ └── workflow/ # Workflow state machine & telemetry workflow store
│ ├── vespa/ # cogniverse_vespa
│ │ ├── pyproject.toml
│ │ ├── README.md
│ │ └── cogniverse_vespa/
│ │ ├── backend.py # Main backend implementation
│ │ ├── search_backend.py # Search backend
│ │ ├── vespa_schema_manager.py # Schema deployment
│ │ ├── config/ # Vespa configuration
│ │ └── registry/ # Adapter registry
│ ├── synthetic/ # cogniverse_synthetic
│ │ ├── pyproject.toml
│ │ ├── README.md
│ │ └── cogniverse_synthetic/
│ │ ├── __init__.py
│ │ ├── approval/ # Approval data generation
│ │ ├── generators/ # Synthetic data generators
│ │ └── utils/ # Utility functions
│ ├── finetuning/ # cogniverse_finetuning
│ │ ├── pyproject.toml
│ │ ├── README.md
│ │ └── cogniverse_finetuning/
│ │ ├── __init__.py
│ │ ├── dataset/ # Dataset preparation
│ │ ├── evaluation/ # Fine-tuned model evaluation
│ │ ├── registry/ # Model/adapter registry
│ │ └── training/ # LoRA/DPO trainers
│ │
│ ├── APPLICATION LAYER (user-facing applications)
│ ├── runtime/ # cogniverse_runtime
│ │ ├── pyproject.toml
│ │ ├── README.md
│ │ └── cogniverse_runtime/
│ │ ├── main.py # FastAPI application
│ │ ├── admin/ # Admin endpoints
│ │ ├── ingestion/ # Data ingestion
│ │ ├── ingestion_worker/ # Redis-Streams ingestion worker
│ │ └── routers/ # API routers
│ ├── cli/ # cogniverse_cli (standalone, no cogniverse deps)
│ │ ├── pyproject.toml
│ │ └── cogniverse_cli/
│ │ ├── main.py # `cogniverse` Click entry point
│ │ ├── admin.py # Tenant/orphan-reconciliation commands
│ │ ├── deploy.py # Schema/chart deployment commands
│ │ ├── cluster.py # Cluster management commands
│ │ └── modal_inference/ # Installed Modal app definitions
│ │ └── servers/ # CLAP, face, GLiNER, X-CLIP HTTP servers
│ └── messaging/ # cogniverse_messaging (standalone, no cogniverse deps)
│ ├── pyproject.toml
│ └── cogniverse_messaging/
│ ├── gateway.py # Telegram gateway (MessagingGateway)
│ ├── command_router.py
│ ├── telegram_handler.py
│ └── runtime_client.py
├── tests/ # Workspace-level tests
│ ├── admin/
│ ├── agents/
│ ├── backends/
│ ├── charts/
│ ├── cli/
│ ├── common/
│ ├── core/
│ ├── e2e/
│ ├── evaluation/
│ ├── events/
│ ├── finetuning/
│ ├── fixtures/
│ ├── foundation/
│ ├── ingestion/
│ ├── memory/
│ ├── messaging/
│ ├── routing/
│ ├── runtime/
│ ├── synthetic/
│ ├── system/
│ ├── telemetry/
│ └── utils/
└── scripts/ # Operational scripts
Package Dependency Graph¶
flowchart TB
subgraph Foundation["<span style='color:#000'>FOUNDATION LAYER</span>"]
SDK["<span style='color:#000'>cogniverse_sdk<br/>Base types & protocols</span>"]
FoundationPkg["<span style='color:#000'>cogniverse_foundation<br/>Telemetry, config, cache, DSPy, registry</span>"]
end
subgraph Core["<span style='color:#000'>CORE LAYER</span>"]
Evaluation["<span style='color:#000'>cogniverse_evaluation<br/>Evaluation framework</span>"]
CorePkg["<span style='color:#000'>cogniverse_core<br/>Interfaces, registries, schemas</span>"]
end
subgraph Implementation["<span style='color:#000'>IMPLEMENTATION LAYER</span>"]
TelemetryPhoenix["<span style='color:#000'>cogniverse_telemetry_phoenix<br/>Phoenix telemetry</span>"]
Agents["<span style='color:#000'>cogniverse_agents<br/>Agent implementations</span>"]
Vespa["<span style='color:#000'>cogniverse_vespa<br/>Backend integration</span>"]
Synthetic["<span style='color:#000'>cogniverse_synthetic<br/>Synthetic data generation</span>"]
Finetuning["<span style='color:#000'>cogniverse_finetuning<br/>LLM fine-tuning</span>"]
end
subgraph Application["<span style='color:#000'>APPLICATION LAYER</span>"]
Runtime["<span style='color:#000'>cogniverse_runtime<br/>FastAPI server</span>"]
CLI["<span style='color:#000'>cogniverse_cli<br/>Click CLI (no cogniverse deps)</span>"]
Messaging["<span style='color:#000'>cogniverse_messaging<br/>Telegram gateway (no cogniverse deps)</span>"]
end
FoundationPkg --> SDK
Evaluation --> FoundationPkg
Evaluation --> SDK
CorePkg --> FoundationPkg
CorePkg --> SDK
CorePkg --> Evaluation
TelemetryPhoenix --> CorePkg
TelemetryPhoenix --> Evaluation
Agents --> SDK
Agents --> CorePkg
Agents --> Synthetic
Vespa --> SDK
Vespa --> CorePkg
Synthetic --> SDK
Synthetic --> FoundationPkg
Synthetic --> CorePkg
Finetuning --> SDK
Finetuning --> CorePkg
Finetuning --> Agents
Finetuning --> Synthetic
Finetuning --> FoundationPkg
Runtime --> SDK
Runtime --> CorePkg
Runtime --> Synthetic
Runtime -.-> Agents
Runtime -.-> Vespa
style SDK fill:#a5d6a7,stroke:#388e3c,color:#000
style FoundationPkg fill:#a5d6a7,stroke:#388e3c,color:#000
style Evaluation fill:#ce93d8,stroke:#7b1fa2,color:#000
style CorePkg fill:#ce93d8,stroke:#7b1fa2,color:#000
style TelemetryPhoenix fill:#ffcc80,stroke:#ef6c00,color:#000
style Agents fill:#ffcc80,stroke:#ef6c00,color:#000
style Vespa fill:#ffcc80,stroke:#ef6c00,color:#000
style Synthetic fill:#ffcc80,stroke:#ef6c00,color:#000
style Finetuning fill:#ffcc80,stroke:#ef6c00,color:#000
style Runtime fill:#90caf9,stroke:#1565c0,color:#000
style CLI fill:#90caf9,stroke:#1565c0,color:#000
style Messaging fill:#90caf9,stroke:#1565c0,color:#000 Layered Dependency Rules:
Foundation Layer (no dependencies on other Cogniverse packages):
-
cogniverse_sdk: Base types and protocols -
cogniverse_foundation: Core telemetry, configuration, cache, utilities (depends onsdk)
Core Layer (depends only on foundation):
-
cogniverse_evaluation: Depends onfoundation,sdk -
cogniverse_core: Depends onfoundation,sdk,evaluation
Implementation Layer (depends on core and foundation):
-
cogniverse_telemetry_phoenix: Depends oncore,evaluation -
cogniverse_agents: Depends onsdk,core,synthetic -
cogniverse_vespa: Depends onsdk,core -
cogniverse_synthetic: Depends onsdk,foundation,core -
cogniverse_finetuning: Depends onsdk,core,agents,synthetic,foundation
Application Layer (depends on lower layers as needed):
-
cogniverse_runtime: Depends onsdk,core,synthetic(optional:agents,vespa) -
cogniverse_cli: Standalone Click CLI — no dependencies on other Cogniverse packages (talks to the runtime over HTTP) -
cogniverse_messaging: Standalone Telegram gateway — no dependencies on other Cogniverse packages (talks to the runtime over HTTP)
Development Workflows¶
Initial Setup¶
1. Clone and Install Workspace:
# Clone repository
git clone <repository-url>
cd cogniverse
# Install uv if not already installed
pip install uv
# Sync entire workspace (all packages in editable mode)
uv sync
# Verify installation
uv pip list | grep cogniverse
# Expected (12 packages in dependency order):
# cogniverse-sdk 0.1.0
# cogniverse-foundation 0.1.0
# cogniverse-evaluation 0.1.0
# cogniverse-core 0.1.0
# cogniverse-telemetry-phoenix 0.1.0
# cogniverse-agents 0.1.0
# cogniverse-vespa 0.1.0
# cogniverse-synthetic 0.1.0
# cogniverse-finetuning 0.1.0
# cogniverse-runtime 0.1.0
# cogniverse-cli 0.1.0
# cogniverse-messaging 0.1.0
2. Activate Virtual Environment:
# Activate workspace virtual environment
source .venv/bin/activate # Linux/macOS
# or
.venv\Scripts\activate # Windows
# Verify Python path
which python
# Should point to: /path/to/cogniverse/.venv/bin/python
Working on Individual Packages¶
Scenario 1: Developing Foundation Package (Base Layer)
# Navigate to foundation package
cd libs/foundation
# Add a new dependency
uv add pydantic
# Update existing dependency
uv add --upgrade pydantic
# Remove dependency
uv remove pydantic
# Sync workspace after changes
cd ../..
uv sync
# Test foundation package
uv run pytest tests/telemetry/ -v
Scenario 2: Developing Agents Package (Implementation Layer)
# Navigate to agents package
cd libs/agents
# Add dependency (will automatically install if needed)
uv add litellm
# Since agents depends on core and synthetic, changes to those are immediately available
# Edit code in cogniverse_agents/orchestrator_agent.py
from cogniverse_foundation.config.unified_config import SystemConfig # Uses editable foundation
from cogniverse_core.registries.backend_registry import BackendRegistry # Uses editable core
# Run tests for this package only
uv run pytest tests/agents/ -v
Scenario 2b: Developing Synthetic Package (Implementation Layer)
# Navigate to synthetic package
cd libs/synthetic
# Add dependencies
uv add faker # For synthetic data generation
# synthetic depends on sdk, foundation, and core — keep dependencies
# beyond those minimal
from pydantic import BaseModel, Field
# Run tests
uv run pytest tests/synthetic/ -v
Scenario 3: Cross-Layer Development
# Scenario: Adding a new feature that spans multiple layers
# 1. Start with foundation layer (base types/utilities)
cd libs/foundation
# Edit cogniverse_foundation/telemetry/manager.py
# Add new telemetry capability
# 2. Update evaluation package (core layer) to use new telemetry
cd ../evaluation
# Edit cogniverse_evaluation/core/experiment_tracker.py
from cogniverse_foundation.telemetry.manager import TelemetryManager
telemetry = TelemetryManager()
# Use new telemetry capability
# 3. Update core package (core layer) for business logic
cd ../core
# Edit cogniverse_core/memory/backend_config.py
# Add new configuration field for tenant memory settings
# 4. Update agents package (implementation layer) to use new config
cd ../agents
# Edit cogniverse_agents/orchestrator_agent.py
from cogniverse_foundation.config.unified_config import SystemConfig
from cogniverse_core.registries.backend_registry import BackendRegistry
# Use new tenant memory config
# 5. Update runtime (application layer) to expose new feature
cd ../runtime
# Edit cogniverse_runtime/routers/admin.py or cogniverse_runtime/main.py
# Add endpoint for tenant memory configuration
# 6. Sync workspace to ensure all changes are available
cd ../../..
uv sync
# 7. Run layer-aware tests
# Foundation layer tests
uv run pytest tests/telemetry/ tests/common/ -v
# Core layer tests
uv run pytest tests/evaluation/ tests/memory/ -v
# Implementation layer tests
JAX_PLATFORM_NAME=cpu uv run pytest tests/agents/ tests/synthetic/ -v
# Application layer tests
uv run pytest tests/runtime/ -v
Running Scripts and Applications¶
Using uv run for Scripts:
# Run ingestion script
JAX_PLATFORM_NAME=cpu uv run python scripts/run_ingestion.py \
--video_dir data/testset/evaluation/sample_videos \
--backend vespa \
--tenant-id acme_corp
# Open the web client (deployed by `cogniverse up`)
open http://localhost:28400
# Run experiments
uv run python scripts/run_experiments_with_visualization.py \
--tenant-id acme:acme \
--dataset-name golden_eval_v1 \
--profiles frame_based_colpali
Direct Python Imports (in Scripts):
# scripts/custom_script.py
# Import from foundation layer
from cogniverse_foundation.telemetry.manager import TelemetryManager
from cogniverse_foundation.telemetry.config import TelemetryConfig
# Import from core layer
from cogniverse_foundation.config.unified_config import SystemConfig
from cogniverse_core.registries.backend_registry import BackendRegistry
from cogniverse_core.schemas.filesystem_loader import FilesystemSchemaLoader
from cogniverse_evaluation.core.experiment_tracker import ExperimentTracker
# Import from implementation layer
from cogniverse_agents.gateway_agent import GatewayAgent
from cogniverse_synthetic.generators.profile import ProfileGenerator
from pathlib import Path
from cogniverse_foundation.config.utils import create_default_config_manager
# All packages available in editable mode
config_manager = create_default_config_manager()
schema_loader = FilesystemSchemaLoader(Path("configs/schemas"))
backend = BackendRegistry.get_search_backend(
name="vespa",
config_manager=config_manager, schema_loader=schema_loader
)
# TelemetryManager is a singleton class - use constructor to get instance
telemetry = TelemetryManager(config=TelemetryConfig())
# GatewayAgent classifies queries using GLiNER (no config needed for defaults)
from cogniverse_agents.gateway_agent import GatewayDeps
gateway_deps = GatewayDeps()
gateway = GatewayAgent(deps=gateway_deps)
Dependency Management¶
Adding Dependencies¶
Package-Level Dependencies:
# Navigate to specific package
cd libs/core
# Add runtime dependency
uv add httpx
# Add with version constraint
uv add "pydantic>=2.0,<3.0"
# Add optional dependency group
uv add --optional telemetry arize-phoenix-otel
# Add development dependency
uv add --dev pytest-asyncio
Workspace Root Dependencies:
# Add dependency used across multiple packages
cd /path/to/cogniverse
uv add ruff # Code formatter/linter
# Add test dependency for workspace
uv add --dev pytest pytest-cov
Managing Inter-Package Dependencies¶
Example: Adding New Foundation Feature Used by Upper Layers
Step 1: Update foundation package (base layer):
# libs/foundation/pyproject.toml
[project]
name = "cogniverse-foundation"
version = "0.2.0" # Increment version
dependencies = [
"cogniverse-sdk>=0.2.0", # SDK dependency
"pydantic>=2.0",
"httpx>=0.25.0",
]
Step 2: Update evaluation package (core layer) to use new foundation:
# libs/evaluation/pyproject.toml
[project]
name = "cogniverse-evaluation"
version = "0.2.0"
dependencies = [
"cogniverse-foundation>=0.2.0", # Update minimum version
"arize-phoenix-client>=3.5.0",
]
Step 3: Update core package (core layer):
# libs/core/pyproject.toml
[project]
name = "cogniverse-core"
version = "0.2.0"
dependencies = [
"cogniverse-foundation>=0.2.0", # Foundation dependency
"cogniverse-sdk>=0.2.0", # SDK dependency
"mem0ai>=0.1.0",
]
Step 4: Update agents (implementation layer) to use new core:
# libs/agents/pyproject.toml
[project]
name = "cogniverse-agents"
version = "0.2.0"
dependencies = [
"cogniverse-core>=0.2.0", # Core dependency
"cogniverse-evaluation>=0.2.0", # Evaluation dependency
"litellm>=1.0.0",
]
Step 5: Sync workspace (propagates changes through all layers):
Dependency Resolution¶
Understanding uv.lock:
# View lockfile (contains exact versions for all 12 packages + dependencies)
cat uv.lock
# Regenerate lockfile (after pyproject.toml changes)
uv lock
# Upgrade all dependencies to latest compatible versions
uv lock --upgrade
# Upgrade specific package
uv add --upgrade pydantic
Resolving Conflicts Across Layers:
# Scenario: Multiple packages in different layers require different versions of same dependency
# libs/foundation/pyproject.toml requires: httpx>=0.25.0,<0.26.0
# libs/agents/pyproject.toml requires: httpx>=0.24.0
# libs/runtime/pyproject.toml requires: httpx>=0.25.0
# uv will resolve to: httpx==0.25.x (satisfies all layers)
# If incompatible, uv will report error:
# ERROR: Cannot resolve dependencies:
# cogniverse-foundation requires httpx>=0.25.0,<0.26.0
# cogniverse-agents requires httpx>=0.27.0
# Solution: Align version constraints across layers in pyproject.toml files
# Start with foundation layer and propagate upward
Building Packages¶
Building Distribution Packages¶
Build All Packages (in dependency order):
# Build all 12 SDK packages for distribution (order matters!)
# Foundation layer first
for dir in libs/sdk libs/foundation; do
echo "Building $(basename $dir)..."
(cd "$dir" && uv build)
done
# Core layer
for dir in libs/evaluation libs/core; do
echo "Building $(basename $dir)..."
(cd "$dir" && uv build)
done
# Implementation layer
for dir in libs/telemetry-phoenix libs/agents libs/vespa libs/synthetic libs/finetuning; do
echo "Building $(basename $dir)..."
(cd "$dir" && uv build)
done
# Application layer (cli and messaging have no cogniverse deps, build anytime)
for dir in libs/runtime libs/cli libs/messaging; do
echo "Building $(basename $dir)..."
(cd "$dir" && uv build)
done
# Output (in each libs/*/dist/):
# cogniverse_sdk-0.1.0-py3-none-any.whl
# cogniverse_sdk-0.1.0.tar.gz
# cogniverse_foundation-0.1.0-py3-none-any.whl
# cogniverse_foundation-0.1.0.tar.gz
# ... (all 12 packages)
Build Individual Package:
# Build core package only
cd libs/core
uv build
# Verify build artifacts
ls -lh dist/
# cogniverse_core-0.1.0-py3-none-any.whl
# cogniverse_core-0.1.0.tar.gz
# Inspect wheel contents
unzip -l dist/cogniverse_core-0.1.0-py3-none-any.whl
Installing from Built Wheels¶
Local Installation:
# Create test environment
python -m venv test_env
source test_env/bin/activate
# Install core package from wheel
pip install libs/core/dist/cogniverse_core-0.1.0-py3-none-any.whl
# Install agents (will automatically install core dependency)
pip install libs/agents/dist/cogniverse_agents-0.1.0-py3-none-any.whl
# Verify imports
python -c "from cogniverse_foundation.config.unified_config import SystemConfig; print('Success!')"
Installation Order Matters (Layer-Aware):
# CORRECT: Install in layer dependency order
# Foundation layer
pip install dist/cogniverse_sdk-0.1.0-py3-none-any.whl
pip install dist/cogniverse_foundation-0.1.0-py3-none-any.whl
# Core layer
pip install dist/cogniverse_evaluation-0.1.0-py3-none-any.whl
pip install dist/cogniverse_core-0.1.0-py3-none-any.whl
# Implementation layer
pip install dist/cogniverse_telemetry_phoenix-0.1.0-py3-none-any.whl
pip install dist/cogniverse_agents-0.1.0-py3-none-any.whl
pip install dist/cogniverse_vespa-0.1.0-py3-none-any.whl
pip install dist/cogniverse_synthetic-0.1.0-py3-none-any.whl
pip install dist/cogniverse_finetuning-0.1.0-py3-none-any.whl
# Application layer
pip install dist/cogniverse_runtime-0.1.0-py3-none-any.whl
# INCORRECT: May fail due to missing dependencies
pip install dist/cogniverse_runtime-0.1.0-py3-none-any.whl # Needs all lower layers
Build Verification¶
Verify Package Metadata:
# Check package metadata
cd libs/core
uv build
pip show cogniverse-core
# Output:
# Name: cogniverse-core
# Version: 0.1.0
# Summary: Core utilities for Cogniverse multi-agent system
# Home-page: https://github.com/yourorg/cogniverse
# Author: Your Name
# License: MIT
# Requires: pydantic, httpx, arize-phoenix-otel
# Required-by: cogniverse-agents, cogniverse-vespa
Test Installed Packages (Layer-by-Layer):
# test_package_install.py
# Test foundation layer
import cogniverse_sdk
import cogniverse_foundation
from cogniverse_foundation.telemetry.manager import TelemetryManager
from cogniverse_foundation.telemetry.config import TelemetryConfig
# Test core layer
import cogniverse_evaluation
import cogniverse_core
from cogniverse_foundation.config.unified_config import SystemConfig
from cogniverse_evaluation.core.experiment_tracker import ExperimentTracker
# Test implementation layer
import cogniverse_telemetry_phoenix
import cogniverse_agents
import cogniverse_vespa
import cogniverse_synthetic
import cogniverse_finetuning
from cogniverse_agents.gateway_agent import GatewayAgent
# Test application layer
import cogniverse_runtime
import cogniverse_cli
import cogniverse_messaging
# Verify installed versions via package metadata (most packages don't
# define a module-level __version__ attribute — use importlib.metadata)
from importlib.metadata import version
assert version("cogniverse-sdk") == "0.1.0"
assert version("cogniverse-foundation") == "0.1.0"
assert version("cogniverse-core") == "0.1.0"
# ... verify all 12 packages
# Test basic functionality
config = SystemConfig()
assert config.search_backend == "vespa"
# TelemetryManager is a singleton class
telemetry = TelemetryManager(config=TelemetryConfig())
assert telemetry is not None
print("✅ All 12 packages installed and verified")
Testing Strategies¶
Package-Specific Testing¶
Test Core Package:
# Run all core package tests
uv run pytest tests/common/ tests/telemetry/ -v
# Run with coverage
uv run pytest tests/common/ --cov=cogniverse_core --cov-report=html
# View coverage report
open htmlcov/index.html
Test Agents Package:
# Run agents tests
JAX_PLATFORM_NAME=cpu timeout 1800 uv run pytest tests/agents/ -v --tb=line
# Run specific test file
uv run pytest tests/agents/unit/ -v
# Run with markers
uv run pytest tests/agents/ -m "not slow" -v
Test Integration:
# Run integration tests (multiple packages)
JAX_PLATFORM_NAME=cpu timeout 7200 uv run pytest \
tests/memory/ \
tests/ingestion/integration/ \
tests/evaluation/ \
tests/routing/ \
-v --tb=line
Test Organization¶
Per-Package Test Structure:
tests/
├── agents/ # cogniverse_agents tests
│ ├── unit/
│ │ ├── test_orchestrator_agent.py
│ │ └── test_agent_registry_http.py
│ └── integration/
│ └── test_a2a_real_services.py
├── common/ # cogniverse_core.common tests
│ ├── unit/
│ │ ├── test_agent_config.py
│ │ └── test_dynamic_dspy_mixin.py
│ └── integration/
│ └── test_config_persistence.py
├── evaluation/ # cogniverse_evaluation tests
│ └── unit/
│ ├── test_experiment_tracker.py
│ └── test_evaluators.py
├── ingestion/ # cogniverse_runtime.ingestion tests
│ ├── unit/
│ │ └── test_pipeline.py
│ └── integration/
│ └── test_backend_ingestion.py
├── memory/ # cogniverse_core.memory tests
│ ├── unit/
│ │ └── test_mem0_memory_manager.py
│ └── integration/
│ └── test_mem0_vespa_integration.py
└── routing/ # cogniverse_agents.routing tests
├── unit/
│ ├── test_xgboost_meta_models.py
│ └── test_multi_modal_reranker.py
└── integration/
└── test_deep_research_integration.py
Testing Best Practices¶
1. Use Fixtures for Package Dependencies:
# tests/conftest.py
import pytest
from pathlib import Path
from cogniverse_foundation.config.unified_config import SystemConfig
from cogniverse_core.registries.backend_registry import BackendRegistry
from cogniverse_core.schemas.filesystem_loader import FilesystemSchemaLoader
from cogniverse_foundation.config.utils import create_default_config_manager
@pytest.fixture
def config_manager():
"""Shared config manager for tests"""
return create_default_config_manager()
@pytest.fixture
def schema_loader():
"""Shared schema loader for tests"""
return FilesystemSchemaLoader(Path("configs/schemas"))
@pytest.fixture
def vespa_backend(config_manager, schema_loader):
"""Vespa backend for integration tests"""
return BackendRegistry.get_search_backend(
name="vespa",
config_manager=config_manager,
schema_loader=schema_loader
)
2. Isolate Package Tests:
# tests/agents/unit/test_orchestrator_agent.py
from cogniverse_agents.orchestrator_agent import OrchestratorAgent, OrchestratorDeps, OrchestratorInput
from cogniverse_core.registries.agent_registry import AgentRegistry
def test_orchestrator_initialization(config_manager):
"""Test agent initialization (no external dependencies)"""
registry = AgentRegistry(tenant_id="test_tenant", config_manager=config_manager)
agent = OrchestratorAgent(deps=OrchestratorDeps(), registry=registry, config_manager=config_manager)
assert agent.deps is not None
async def test_orchestrator_decision(config_manager):
"""Test orchestrator plan execution"""
registry = AgentRegistry(tenant_id="test_tenant", config_manager=config_manager)
agent = OrchestratorAgent(deps=OrchestratorDeps(), registry=registry, config_manager=config_manager)
result = await agent._process_impl(
OrchestratorInput(query="test query", tenant_id="test:unit")
)
assert result.workflow_id != ""
assert result.execution_summary != ""
3. Integration Tests Across Packages:
# tests/ingestion/integration/test_backend_ingestion.py
import pytest
from cogniverse_runtime.ingestion.pipeline import VideoIngestionPipeline
from cogniverse_vespa.backend import VespaBackend
from cogniverse_foundation.config.unified_config import SystemConfig
@pytest.mark.integration
async def test_video_ingestion_to_vespa(vespa_backend, sample_video, config_manager, schema_loader):
"""Test complete ingestion pipeline with real Vespa"""
pipeline = VideoIngestionPipeline(
tenant_id="test",
config_manager=config_manager,
schema_loader=schema_loader,
schema_name="video_colpali_smol500_mv_frame_test"
)
result = await pipeline.process_video_async(sample_video)
assert result["status"] == "completed"
# Verify in Vespa
docs = vespa_backend.search({
"query": "test",
"type": "video",
"profile": "video_colpali_smol500_mv_frame_test",
})
assert len(docs) > 0
Versioning and Releases¶
Semantic Versioning¶
Version Format: MAJOR.MINOR.PATCH
0.1.0 → Initial release
0.1.1 → Patch release (bug fixes)
0.2.0 → Minor release (new features, backward compatible)
1.0.0 → Major release (breaking changes)
Version Bump Strategy:
PATCH (0.1.0 → 0.1.1):
-
Bug fixes
-
Documentation updates
-
Performance improvements (no API changes)
MINOR (0.1.0 → 0.2.0):
-
New features (backward compatible)
-
New optional parameters
-
Deprecation warnings
-
Internal refactoring
MAJOR (0.2.0 → 1.0.0):
-
Breaking API changes
-
Removed deprecated features
-
Changed function signatures
-
Renamed modules/classes
Release Process¶
Step 1: Update Version Numbers
# Update core package version
# libs/core/pyproject.toml
[project]
name = "cogniverse-core"
version = "0.2.0" # Increment version
# Update agents package (depends on core)
# libs/agents/pyproject.toml
[project]
name = "cogniverse-agents"
version = "0.2.0"
dependencies = [
"cogniverse-core>=0.2.0", # Update dependency
]
Step 2: Update Changelog
# CHANGELOG.md
## [0.2.0] - 2025-10-15
### Added
- Multi-tenant memory isolation with Mem0
- Per-tenant Phoenix project support
- Tenant-aware schema deployment
### Changed
- Refactored TelemetryManager for multi-tenant support
### Fixed
- Fixed memory leak in embedding cache
- Resolved race condition in concurrent video processing
### Breaking Changes
- Removed deprecated `use_default_config()` method
Step 3: Build Packages
# Build all packages
for dir in libs/*/; do
echo "Building $(basename $dir) v0.2.0..."
(cd "$dir" && uv build)
done
Step 4: Test Built Packages
# Create clean test environment
python -m venv release_test_env
source release_test_env/bin/activate
# Install in dependency order
pip install libs/core/dist/cogniverse_core-0.2.0-py3-none-any.whl
pip install libs/vespa/dist/cogniverse_vespa-0.2.0-py3-none-any.whl
pip install libs/agents/dist/cogniverse_agents-0.2.0-py3-none-any.whl
# Run smoke tests
python -c "
from cogniverse_foundation.telemetry.config import TelemetryConfig
from cogniverse_agents.orchestrator_agent import OrchestratorAgent, OrchestratorDeps
from cogniverse_core.registries.agent_registry import AgentRegistry
from cogniverse_foundation.config.utils import create_default_config_manager
from cogniverse_foundation.config.unified_config import LLMEndpointConfig
deps = OrchestratorDeps(
telemetry_config=TelemetryConfig(),
llm_config=LLMEndpointConfig(
model='openai/google/gemma-4-e4b-it',
api_base='http://localhost:11434/v1',
),
)
config_manager = create_default_config_manager()
registry = AgentRegistry(tenant_id='acme', config_manager=config_manager)
agent = OrchestratorAgent(deps, registry, config_manager=config_manager)
print('Release smoke test passed')
"
Step 5: Tag Release
Step 6: Publish to PyPI (Optional)
# Publish core package
cd libs/core
uv publish
# Publish other packages (in dependency order)
cd ../vespa && uv publish
cd ../agents && uv publish
cd ../runtime && uv publish
Version Compatibility Matrix (Key Packages)¶
| Package | Version | Requires SDK | Requires Foundation | Requires Core | Requires Evaluation | Requires Synthetic | Requires Agents | Requires Runtime |
|---|---|---|---|---|---|---|---|---|
| cogniverse-sdk | 0.2.0 | - | - | - | - | - | - | - |
| cogniverse-foundation | 0.2.0 | >=0.2.0 | - | - | - | - | - | - |
| cogniverse-evaluation | 0.2.0 | >=0.2.0 | >=0.2.0 | - | - | - | - | - |
| cogniverse-core | 0.2.0 | >=0.2.0 | >=0.2.0 | - | >=0.2.0 | - | - | - |
| cogniverse-telemetry-phoenix | 0.2.0 | - | - | >=0.2.0 | >=0.2.0 | - | - | - |
| cogniverse-agents | 0.2.0 | >=0.2.0 | - | >=0.2.0 | - | >=0.2.0 | - | - |
| cogniverse-vespa | 0.2.0 | >=0.2.0 | - | >=0.2.0 | - | - | - | - |
| cogniverse-synthetic | 0.2.0 | >=0.2.0 | >=0.2.0 | >=0.2.0 | - | - | - | - |
| cogniverse-finetuning | 0.2.0 | >=0.2.0 | >=0.2.0 | >=0.2.0 | - | >=0.2.0 | >=0.2.0 | - |
| cogniverse-runtime | 0.2.0 | >=0.2.0 | - | >=0.2.0 | - | >=0.2.0 | - | - |
Note: This shows required dependencies only (columns cover the packages most often bumped together; cli and messaging are omitted because they carry no cogniverse-* dependencies at any version). Runtime has optional dependencies on agents and vespa.
Best Practices¶
1. Package Organization¶
Keep Packages Focused:
# ✅ GOOD: Clear package boundaries
# cogniverse_foundation - foundational utilities only
from cogniverse_foundation.config.unified_config import SystemConfig
from cogniverse_foundation.telemetry.manager import TelemetryManager
# cogniverse_agents - agent implementations only
from cogniverse_agents.orchestrator_agent import OrchestratorAgent
from cogniverse_agents.search_agent import SearchAgent
# ❌ BAD: Mixing concerns
# Don't put agent implementations in cogniverse_foundation
# Don't put foundational utilities in cogniverse_agents
Avoid Circular Dependencies:
# ❌ BAD: Circular dependency
# libs/foundation/cogniverse_foundation/config/unified_config.py
from cogniverse_agents.orchestrator_agent import OrchestratorAgent # ❌ foundation depends on agents
# ✅ GOOD: One-way dependency
# libs/agents/cogniverse_agents/orchestrator_agent.py
from cogniverse_foundation.config.unified_config import SystemConfig # ✅ agents depends on foundation
2. Import Conventions¶
Use Absolute Imports:
# ✅ GOOD: Absolute imports from package root
from cogniverse_foundation.config.unified_config import SystemConfig
from cogniverse_foundation.telemetry.manager import TelemetryManager
from cogniverse_agents.orchestrator_agent import OrchestratorAgent
# ❌ BAD: Relative imports across packages
from ...core.config import SystemConfig # ❌ Hard to read
from ..agents.orchestrator_agent import OrchestratorAgent # ❌ Fragile
Package-Level Exports:
# libs/core/cogniverse_core/__init__.py
# Note: This package's __init__.py is intentionally empty (no exports)
# Always import directly from submodules for explicit dependencies
# Usage (use full import paths):
from cogniverse_foundation.config.unified_config import SystemConfig
from cogniverse_foundation.telemetry.manager import TelemetryManager
from cogniverse_evaluation.core.experiment_tracker import ExperimentTracker
from cogniverse_core.registries.backend_registry import BackendRegistry
3. Dependency Hygiene¶
Minimal Dependencies:
# ✅ GOOD: Only essential dependencies
[project]
dependencies = [
"pydantic>=2.0",
"httpx>=0.25.0",
]
# ❌ BAD: Unnecessary dependencies
[project]
dependencies = [
"pydantic>=2.0",
"httpx>=0.25.0",
"numpy>=1.24.0", # ❌ Not used in core
"pandas>=2.0.0", # ❌ Only used in one file
]
Optional Dependencies:
# Use optional dependency groups for specialized features
[project.optional-dependencies]
telemetry = [
"arize-phoenix-otel>=4.0.0",
"opentelemetry-sdk>=1.20.0",
]
memory = [
"mem0ai>=0.1.0",
]
all = [
"arize-phoenix-otel>=4.0.0",
"opentelemetry-sdk>=1.20.0",
"mem0ai>=0.1.0",
]
# Install with: uv add --optional telemetry arize-phoenix-otel
4. Testing Discipline¶
Test Coverage Requirements:
# Maintain >80% coverage for all packages
uv run pytest tests/agents/ --cov=cogniverse_agents --cov-fail-under=80
# ✅ Coverage report:
# cogniverse_agents/orchestrator_agent.py 95%
# cogniverse_agents/search_agent.py 87%
# cogniverse_agents/gateway_agent.py 82%
# TOTAL 88%
Test Before Commit:
# Pre-commit checklist
uv run ruff check . # Linting
uv run ruff format . # Formatting
uv run pytest tests/ -v # All tests
uv build # Build verification
5. Documentation Standards¶
Package README.md:
# cogniverse-agents
Agent implementations for Cogniverse multi-agent AI platform.
## Installation
```bash
pip install cogniverse-agents
Quick Start¶
import asyncio
from cogniverse_agents.gateway_agent import GatewayAgent, GatewayDeps, GatewayInput
async def main():
# GatewayAgent classifies queries using GLiNER (no LLM config needed for defaults)
deps = GatewayDeps()
agent = GatewayAgent(deps=deps)
result = await agent.process(GatewayInput(
query="Show me machine learning videos",
tenant_id="acme"
))
print(f"Route to: {result.routed_to}")
asyncio.run(main())
Features¶
- Intelligent query routing with GLiNER and LLM strategies
- Video search with ColPali and X-CLIP
- Multi-tenant support with schema isolation
- Phoenix telemetry integration
Documentation¶
**Docstring Standards:**
```python
def process_video(
self,
video_path: Path,
tenant_id: str,
profile: str = "video_colpali_smol500_mv_frame"
) -> dict:
"""
Process video and upload to tenant-specific Vespa schema.
Args:
video_path: Path to video file
tenant_id: Tenant identifier for schema isolation
profile: Processing profile name (default: frame-based ColPali)
Returns:
Dict with keys:
- status: "success" or "failed"
- documents_created: Number of documents uploaded
- processing_time: Time in seconds
- schema_name: Tenant-specific schema name
Raises:
VideoProcessingError: If video processing fails
VespaUploadError: If upload to Vespa fails
Examples:
>>> pipeline = VideoIngestionPipeline(tenant_id="acme_corp", config_manager=config_manager)
>>> result = await pipeline.process_video_async(Path("video.mp4"))
>>> print(result["status"])
'completed'
"""
6. CI/CD Integration¶
GitHub Actions Workflow:
# .github/workflows/test-packages.yml
name: Test Packages
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install uv
run: pip install uv
- name: Sync workspace
run: uv sync
- name: Run linter
run: uv run ruff check .
- name: Run formatter
run: uv run ruff format --check .
- name: Run tests
run: |
JAX_PLATFORM_NAME=cpu timeout 7200 uv run pytest \
tests/ -v --tb=line --cov=libs --cov-report=xml
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
Summary¶
This guide covers comprehensive UV workspace package development with layered architecture:
- Package Architecture: layered structure with 4-layer dependency hierarchy
- Development Workflows: Layer-aware editable installs, cross-layer development
- Dependency Management: Layer-specific dependencies and workspace-level dependencies
- Building: Distribution packages with wheels and source distributions in dependency order
- Testing: Per-layer and integration testing strategies
- Versioning: Semantic versioning and release process for all 12 packages
- Best Practices: Layer organization, imports, documentation, CI/CD
Key Principles for Layered Architecture:
-
Foundation Layer (sdk, foundation): Minimal cross-dependencies (foundation depends on sdk)
-
Core Layer (evaluation, core): Depends only on foundation layer
-
Implementation Layer (telemetry-phoenix, agents, vespa, synthetic, finetuning): Depends on core and/or foundation
-
Application Layer (runtime): Depends on lower layers as needed
-
Use
uv syncfor workspace-wide changes across all layers -
Test layer-by-layer before releases
-
Maintain backward compatibility in minor versions
-
Document all public APIs with layer information
-
Optional dependencies (runtime → agents, vespa) use dashed arrows in diagrams
Layer-Aware Development:
-
Start changes in lower layers (foundation) and propagate upward
-
Test each layer independently before integration testing
-
Build and publish in dependency order: foundation → core → implementation → application
-
Version bumps should be coordinated across dependent layers
Next Steps:
-
Scripts & Operations - Operational scripts
-
Testing Guide - Layer-aware testing strategies
-
Deployment Guide - Production deployment
-
Publishing Guide - publishing workflow
Related Documentation: