chasm/schema/mod.rs
1// Copyright (c) 2024-2026 Nervosys LLC
2// SPDX-License-Identifier: AGPL-3.0-only
3//! # Schema Registry & Ontology
4//!
5//! Persistent, versioned database schemas for every AI chat provider and format
6//! version, plus an ontology layer that makes schemas discoverable by AI agents.
7//!
8//! ## Architecture
9//!
10//! ```text
11//! ┌─────────────────────────────────────────────────────────────┐
12//! │ Schema Registry │
13//! │ ┌─────────────┐ ┌────────────-─┐ ┌─────────────┐ │
14//! │ │ Copilot v3 │ │ Copilot JSONL│ │ Cursor v1 │ ... │
15//! │ │ (JSON) │ │ (0.37+) │ │ │ │
16//! │ └─────────────┘ └──────────────┘ └─────────────┘ │
17//! ├─────────────────────────────────────────────────────────────┤
18//! │ Ontology Layer │
19//! │ • Entity types, relationships, field semantics │
20//! │ • Cross-provider mappings (field A in X ≡ field B in Y) │
21//! │ • Version migration paths │
22//! │ • Machine-readable capability descriptors │
23//! └─────────────────────────────────────────────────────────────┘
24//! ```
25//!
26//! ## Usage
27//!
28//! ```rust,ignore
29//! use csm::schema::{SchemaRegistry, SchemaVersion};
30//!
31//! let registry = SchemaRegistry::new();
32//!
33//! // List all known schemas
34//! for schema in registry.list_schemas() {
35//! println!("{}: {} fields", schema.id(), schema.field_count());
36//! }
37//!
38//! // Detect schema for a workspace
39//! let detected = registry.detect_schema("/path/to/workspace")?;
40//!
41//! // Query the ontology
42//! let ontology = registry.ontology();
43//! let mappings = ontology.cross_provider_mappings("copilot-jsonl-v1", "cursor-v1");
44//! ```
45
46mod ontology;
47mod registry;
48mod types;
49mod versions;
50
51pub use ontology::{
52 CrossProviderMapping, EntityRelationship, EntityType, FieldTransform, MigrationPath, Ontology,
53 RelationshipKind, SemanticTag,
54};
55pub use registry::{DetectedSchema, SchemaRegistry};
56pub use types::{
57 DataType, DbKeySchema, FieldConstraint, FieldSchema, FormatType, ProviderSchema, SchemaVersion,
58 SessionFormatSchema, StorageLocation, StorageType,
59};
60pub use versions::{
61 build_all_provider_schemas, claude_code_v1, codex_cli_v1, continue_dev_v1, copilot_json_v3,
62 copilot_jsonl_v1, cursor_v1, gemini_cli_v1, openai_api_v1,
63};