profit 8c6e7831e9 Add Phase 10-12 implementation: multi-tenant, marketplace, observability
Major additions:
- marketplace/: Agent template registry with FTS5 search, ratings, versioning
- observability/: Prometheus metrics, distributed tracing, structured logging
- ledger/migrations/: Database migration scripts for multi-tenant support
- tests/governance/: 15 new test files for phases 6-12 (295 total tests)
- bin/validate-phases: Full 12-phase validation script

New features:
- Multi-tenant support with tenant isolation and quota enforcement
- Agent marketplace with semantic versioning and search
- Observability with metrics, tracing, and log correlation
- Tier-1 agent bootstrap scripts

Updated components:
- ledger/api.py: Extended API for tenants, marketplace, observability
- ledger/schema.sql: Added tenant, project, marketplace tables
- testing/framework.ts: Enhanced test framework
- checkpoint/checkpoint.py: Improved checkpoint management

Archived:
- External integrations (Slack/GitHub/PagerDuty) moved to .archive/
- Old checkpoint files cleaned up

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 18:39:47 -05:00
..

Ledger Migrations

SQL schema migrations for the governance ledger database

Overview

This directory contains SQL migration files that define and evolve the SQLite database schema for the agent governance system. Migrations are numbered sequentially and should be applied in order.

Migration Files

File Phase Description
001_multi_tenant.sql Phase 10 Multi-tenant support tables
002_marketplace.sql Phase 11 Agent marketplace tables

Migration 001: Multi-Tenant Support

Adds tables for multi-tenant architecture:

Table Purpose
tenants Organization/customer records
projects Workspaces within tenants
tenant_quotas Resource limits per tenant
tenant_usage Usage tracking for billing
api_keys API authentication keys
user_roles RBAC role assignments
audit_log_tenant Tenant-scoped audit trail

Migration 002: Marketplace

Adds tables for the agent template marketplace:

Table Purpose
agent_templates Core template registry
template_versions Version history with semver
template_installations Installation tracking
template_ratings User ratings and reviews
template_downloads Download metrics
templates_fts FTS5 full-text search index

Applying Migrations

Migrations are applied automatically when the ledger API starts, or can be applied manually:

# Apply all migrations
sqlite3 /opt/agent-governance/ledger/governance.db < 001_multi_tenant.sql
sqlite3 /opt/agent-governance/ledger/governance.db < 002_marketplace.sql

# Verify tables
sqlite3 /opt/agent-governance/ledger/governance.db ".tables"

Schema Conventions

  • Primary keys: {entity}_id TEXT PRIMARY KEY
  • Timestamps: TEXT DEFAULT CURRENT_TIMESTAMP (ISO 8601)
  • Foreign keys: REFERENCES {table}({column}) ON DELETE CASCADE
  • JSON storage: TEXT columns with JSON content
  • Boolean: INTEGER (0/1)
  • Indices: Created for frequently queried columns

Adding New Migrations

  1. Create file: 00N_description.sql
  2. Use CREATE TABLE IF NOT EXISTS for idempotency
  3. Add indices for query performance
  4. Document in this README
  5. Test with fresh database

Status

Complete

See STATUS.md for detailed progress tracking.

Architecture Reference

Part of the Ledger System.


Last updated: 2026-01-24 UTC