clm-kernel 0.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- clm/__init__.py +230 -0
- clm/__main__.py +25 -0
- clm/cross_cutting/__init__.py +50 -0
- clm/cross_cutting/_test_runner.py +36 -0
- clm/cross_cutting/async_utils.py +25 -0
- clm/cross_cutting/cel_builder.py +123 -0
- clm/cross_cutting/cel_converter.py +697 -0
- clm/cross_cutting/cel_engine.py +252 -0
- clm/cross_cutting/cel_ops.py +72 -0
- clm/cross_cutting/cel_ops_db.py +157 -0
- clm/cross_cutting/cel_ops_files.py +99 -0
- clm/cross_cutting/cel_ops_state.py +71 -0
- clm/cross_cutting/cel_ops_strings.py +64 -0
- clm/cross_cutting/cel_resolver.py +63 -0
- clm/cross_cutting/cel_slices.py +56 -0
- clm/cross_cutting/cel_store.py +330 -0
- clm/cross_cutting/clm_logger.py +140 -0
- clm/cross_cutting/config/__init__.py +155 -0
- clm/cross_cutting/config/config_constants.py +392 -0
- clm/cross_cutting/config/env_parameters.py +90 -0
- clm/cross_cutting/config/logging.py +378 -0
- clm/cross_cutting/config/settings.py +504 -0
- clm/cross_cutting/context.py +5 -0
- clm/cross_cutting/domain_models.py +55 -0
- clm/cross_cutting/domain_types.py +61 -0
- clm/cross_cutting/effects.py +67 -0
- clm/cross_cutting/errors.py +153 -0
- clm/cross_cutting/governance.py +331 -0
- clm/cross_cutting/guards.py +41 -0
- clm/cross_cutting/mcard.py +321 -0
- clm/cross_cutting/native.py +185 -0
- clm/cross_cutting/observability.py +289 -0
- clm/cross_cutting/pcard.py +434 -0
- clm/cross_cutting/registry.py +71 -0
- clm/cross_cutting/resources.py +84 -0
- clm/cross_cutting/secrets.py +44 -0
- clm/cross_cutting/subprocess_utils.py +118 -0
- clm/cross_cutting/telemetry.py +164 -0
- clm/cross_cutting/testing/__init__.py +8 -0
- clm/cross_cutting/testing/comparator.py +187 -0
- clm/cross_cutting/testing/datasets.py +87 -0
- clm/cross_cutting/timeutil.py +20 -0
- clm/cross_cutting/types/new_type_check.py +0 -0
- clm/cross_cutting/utils/__init__.py +1 -0
- clm/cross_cutting/utils/url_safety.py +50 -0
- clm/cross_cutting/vcard.py +560 -0
- clm/cross_cutting/writer.py +118 -0
- clm/layer0/README.md +50 -0
- clm/layer0/__init__.py +223 -0
- clm/layer0/algebra.py +60 -0
- clm/layer0/algebra_baldwin.py +133 -0
- clm/layer0/algebra_baldwin_generators.py +36 -0
- clm/layer0/algebra_equivalence.py +262 -0
- clm/layer0/algebra_ingest.py +306 -0
- clm/layer0/algebra_manifest_io.py +156 -0
- clm/layer0/assembler.py +481 -0
- clm/layer0/cel/__init__.py +23 -0
- clm/layer0/cel_eval.py +491 -0
- clm/layer0/codec.py +106 -0
- clm/layer0/context.py +122 -0
- clm/layer0/db.py +160 -0
- clm/layer0/exceptions.py +73 -0
- clm/layer0/fibration.py +106 -0
- clm/layer0/gates.py +50 -0
- clm/layer0/hash.py +80 -0
- clm/layer0/loader.py +826 -0
- clm/layer0/math_utils.py +163 -0
- clm/layer0/mcard.py +96 -0
- clm/layer0/model/__init__.py +0 -0
- clm/layer0/model/action.py +223 -0
- clm/layer0/model/card.py +280 -0
- clm/layer0/model/card_triad.py +427 -0
- clm/layer0/model/compatibility.py +60 -0
- clm/layer0/model/dictionary.py +46 -0
- clm/layer0/model/dots.py +331 -0
- clm/layer0/model/event_producer.py +88 -0
- clm/layer0/model/g_time.py +89 -0
- clm/layer0/model/handle.py +163 -0
- clm/layer0/model/hash/__init__.py +6 -0
- clm/layer0/model/hash/algorithms/__init__.py +3 -0
- clm/layer0/model/hash/algorithms/custom_hash.py +7 -0
- clm/layer0/model/hash/algorithms/local_sha256.py +178 -0
- clm/layer0/model/hash/constants.py +53 -0
- clm/layer0/model/hash/enums.py +60 -0
- clm/layer0/model/hash/validator.py +307 -0
- clm/layer0/model/interpreter.py +275 -0
- clm/layer0/model/pagination.py +45 -0
- clm/layer0/model/pcard.py +716 -0
- clm/layer0/model/schema.py +44 -0
- clm/layer0/model/utils/__init__.py +1 -0
- clm/layer0/model/utils/content_analyzer.py +152 -0
- clm/layer0/model/validators/__init__.py +1 -0
- clm/layer0/model/validators/base_validator.py +44 -0
- clm/layer0/model/validators/binary_validator.py +66 -0
- clm/layer0/model/validators/text_validator.py +82 -0
- clm/layer0/model/validators/validation_registry.py +49 -0
- clm/layer0/model/vcard.py +823 -0
- clm/layer0/model/vcard_ext/__init__.py +39 -0
- clm/layer0/model/vcard_ext/core.py +60 -0
- clm/layer0/model/vcard_ext/network.py +23 -0
- clm/layer0/model/vcard_ext/observability.py +63 -0
- clm/layer0/model/vcard_ext/storage.py +60 -0
- clm/layer0/model/vcard_ext/vendors.py +211 -0
- clm/layer0/model/vcard_sandwich.py +119 -0
- clm/layer0/model/vcard_vocabulary.py +463 -0
- clm/layer0/model/workflow.py +274 -0
- clm/layer0/narrative.py +431 -0
- clm/layer0/ontology/collection.py +125 -0
- clm/layer0/parser.py +429 -0
- clm/layer0/relations.py +73 -0
- clm/layer0/rule_evaluator.py +251 -0
- clm/layer0/schema/__init__.py +38 -0
- clm/layer0/schema/ddl.py +97 -0
- clm/layer0/templates/abstract.yaml +99 -0
- clm/layer0/templates/balanced.yaml +253 -0
- clm/layer0/templates/concrete.yaml +172 -0
- clm/layer0/type_registry.py +223 -0
- clm/layer0/types.py +204 -0
- clm/layer0/utils.py +886 -0
- clm/layer0/verifier_core.py +262 -0
- clm/layer1/__init__.py +31 -0
- clm/layer1/action_dispatcher.py +275 -0
- clm/layer1/adapter_registry.py +233 -0
- clm/layer1/algebra_baldwin_generators.py +192 -0
- clm/layer1/arrow_compiler.py +525 -0
- clm/layer1/batch_processor.py +152 -0
- clm/layer1/cel/__init__.py +27 -0
- clm/layer1/cel/builder.py +173 -0
- clm/layer1/engine.py +759 -0
- clm/layer1/engine_async.py +89 -0
- clm/layer1/eval_callback.py +49 -0
- clm/layer1/gate_composer.py +229 -0
- clm/layer1/hoare_sandwich.py +298 -0
- clm/layer1/identity_guard.py +348 -0
- clm/layer1/matrix.py +138 -0
- clm/layer1/neural_runtime.py +221 -0
- clm/layer1/operations/__init__.py +123 -0
- clm/layer1/operations/augment.py +156 -0
- clm/layer1/operations/base.py +109 -0
- clm/layer1/operations/builtins.py +338 -0
- clm/layer1/operations/dispatch.py +144 -0
- clm/layer1/operations/exclude.py +107 -0
- clm/layer1/operations/handle.py +197 -0
- clm/layer1/operations/identity.py +139 -0
- clm/layer1/operations/invert.py +66 -0
- clm/layer1/operations/loader.py +116 -0
- clm/layer1/operations/manipulators/__init__.py +23 -0
- clm/layer1/operations/manipulators/document.py +211 -0
- clm/layer1/operations/manipulators/media.py +134 -0
- clm/layer1/operations/manipulators/structured.py +159 -0
- clm/layer1/operations/manipulators/tabular.py +334 -0
- clm/layer1/operations/port.py +65 -0
- clm/layer1/operations/services.py +529 -0
- clm/layer1/operations/split.py +117 -0
- clm/layer1/operations/substitute.py +75 -0
- clm/layer1/petri.py +1052 -0
- clm/layer1/pocketflow_orchestrator.py +408 -0
- clm/layer1/pocketflow_scheduler.py +519 -0
- clm/layer1/protocols.py +197 -0
- clm/layer1/runtime_adapter.py +718 -0
- clm/layer1/runtimes/__init__.py +71 -0
- clm/layer1/runtimes/_generated_assertions.py +125 -0
- clm/layer1/runtimes/_generated_types.py +42 -0
- clm/layer1/runtimes/base.py +265 -0
- clm/layer1/runtimes/binary.py +101 -0
- clm/layer1/runtimes/factory.py +203 -0
- clm/layer1/runtimes/javascript.py +321 -0
- clm/layer1/runtimes/javascript_runtime.js +33 -0
- clm/layer1/runtimes/js_scripts/isomorphism.mjs +22 -0
- clm/layer1/runtimes/js_scripts/loader.mjs +52 -0
- clm/layer1/runtimes/lambda_calc.py +126 -0
- clm/layer1/runtimes/python.py +288 -0
- clm/layer1/runtimes/python_runtime.py +41 -0
- clm/layer1/runtimes/script.py +114 -0
- clm/layer1/sandbox.py +334 -0
- clm/layer1/savepoint_guard.py +136 -0
- clm/layer1/sparse_net.py +122 -0
- clm/layer1/spec_tester.py +165 -0
- clm/layer1/store.py +295 -0
- clm/layer1/test_runner.py +498 -0
- clm/layer1/type_inspector.py +166 -0
- clm/layer1/verifier.py +772 -0
- clm/layer1/vm.py +91 -0
- clm/layer2/__init__.py +78 -0
- clm/layer2/card_collection.py +678 -0
- clm/layer2/classifier.py +479 -0
- clm/layer2/engine/__init__.py +1 -0
- clm/layer2/engine/abstract_sql_engine.py +320 -0
- clm/layer2/engine/base.py +193 -0
- clm/layer2/engine/duckdb_engine.py +576 -0
- clm/layer2/engine/sqlite_engine.py +518 -0
- clm/layer2/fiber/__init__.py +31 -0
- clm/layer2/fiber/context.py +89 -0
- clm/layer2/fiber/disposable.py +163 -0
- clm/layer2/fiber/fiber.py +125 -0
- clm/layer2/fiber/hoare.py +191 -0
- clm/layer2/file_io.py +376 -0
- clm/layer2/file_registrar.py +77 -0
- clm/layer2/ingest.py +202 -0
- clm/layer2/lineage.py +322 -0
- clm/layer2/mcard_fs.py +262 -0
- clm/layer2/merkle.py +11 -0
- clm/layer2/mime.py +244 -0
- clm/layer2/mime_detector.py +245 -0
- clm/layer2/private_collection.py +118 -0
- clm/layer2/shared_store.py +11 -0
- clm/layer2/storage/__init__.py +190 -0
- clm/layer2/storage/db_bitemporal.py +141 -0
- clm/layer2/storage/db_driver.py +331 -0
- clm/layer2/storage/db_hyperlinks.py +214 -0
- clm/layer2/storage/db_pool.py +139 -0
- clm/layer2/storage/db_repository.py +229 -0
- clm/layer2/storage/savepoint.py +78 -0
- clm/layer2/storage/sqlite_wal.py +74 -0
- clm/layer2/tridb.py +245 -0
- clm/layer2/vcard_receipt.py +71 -0
- clm/layer2/vfs.py +17 -0
- clm/layer3/__init__.py +141 -0
- clm/layer3/agency/__init__.py +19 -0
- clm/layer3/agency/config.py +220 -0
- clm/layer3/agency/providers/__init__.py +15 -0
- clm/layer3/agency/providers/base.py +91 -0
- clm/layer3/agency/providers/mlc_llm.py +169 -0
- clm/layer3/agency/providers/ollama.py +203 -0
- clm/layer3/agency/router.py +71 -0
- clm/layer3/agency/runtime.py +524 -0
- clm/layer3/gateway.py +353 -0
- clm/layer3/open_interpreter_adapter.py +159 -0
- clm/layer3/rag/__init__.py +70 -0
- clm/layer3/rag/cli.py +228 -0
- clm/layer3/rag/config.py +153 -0
- clm/layer3/rag/embeddings/__init__.py +16 -0
- clm/layer3/rag/embeddings/base.py +79 -0
- clm/layer3/rag/embeddings/ollama.py +211 -0
- clm/layer3/rag/embeddings/vision.py +290 -0
- clm/layer3/rag/engine.py +276 -0
- clm/layer3/rag/graph/__init__.py +22 -0
- clm/layer3/rag/graph/community.py +198 -0
- clm/layer3/rag/graph/engine.py +433 -0
- clm/layer3/rag/graph/extractor.py +255 -0
- clm/layer3/rag/graph/schema.py +115 -0
- clm/layer3/rag/graph/store.py +641 -0
- clm/layer3/rag/indexer.py +333 -0
- clm/layer3/rag/llm_providers.json +52 -0
- clm/layer3/rag/semantic_versioning.py +313 -0
- clm/layer3/rag/vector/__init__.py +28 -0
- clm/layer3/rag/vector/handle_vector_store.py +749 -0
- clm/layer3/rag/vector/schema.py +151 -0
- clm/layer3/rag/vector/store.py +632 -0
- clm/layer3/reticulum/__init__.py +55 -0
- clm/layer3/reticulum/bridge.py +74 -0
- clm/layer3/reticulum/daemon.py +88 -0
- clm/layer3/reticulum/discovery.py +164 -0
- clm/layer3/reticulum/identity.py +107 -0
- clm/layer3/reticulum/media.py +148 -0
- clm/layer3/reticulum/transport.py +133 -0
- clm/layer3/satori/__init__.py +209 -0
- clm/layer3/satori/alpha_conversion.py +168 -0
- clm/layer3/satori/beta_reduction.py +359 -0
- clm/layer3/satori/continuation.py +38 -0
- clm/layer3/satori/eta_conversion.py +205 -0
- clm/layer3/satori/free_variables.py +163 -0
- clm/layer3/satori/io_effects.py +370 -0
- clm/layer3/satori/lambda_runtime.py +726 -0
- clm/layer3/satori/lambda_term.py +230 -0
- clm/layer3/satori/sheaf_audit.py +261 -0
- clm/layer3/satori/speech_act.py +279 -0
- clm/layer4/README.md +9 -0
- clm/layer4/__init__.py +67 -0
- clm/layer4/_sovereign_executor.py +580 -0
- clm/layer4/action_commands.py +719 -0
- clm/layer4/api.py +236 -0
- clm/layer4/bootstrap/__init__.py +13 -0
- clm/layer4/bootstrap/bootstrapper.py +118 -0
- clm/layer4/bootstrap/cleanup.py +44 -0
- clm/layer4/bootstrap/clm_hooks.py +49 -0
- clm/layer4/bootstrap/genesis.py +77 -0
- clm/layer4/bootstrap/injection.py +125 -0
- clm/layer4/cli.py +549 -0
- clm/layer4/collection_manager.py +553 -0
- clm/layer4/commands/__init__.py +81 -0
- clm/layer4/commands/action_cmd.py +42 -0
- clm/layer4/commands/check_cmd.py +82 -0
- clm/layer4/commands/envelope.py +73 -0
- clm/layer4/commands/evaluate_cmd.py +224 -0
- clm/layer4/commands/mcard_cmd.py +24 -0
- clm/layer4/commands/petri_cmd.py +92 -0
- clm/layer4/commands/tridb_cmd.py +319 -0
- clm/layer4/commands/version_cmd.py +27 -0
- clm/layer4/diff_commands.py +167 -0
- clm/layer4/eoa_sponsor.py +232 -0
- clm/layer4/events.py +69 -0
- clm/layer4/flux_gateway.py +133 -0
- clm/layer4/gateway.py +91 -0
- clm/layer4/loader.py +307 -0
- clm/layer4/mcard_commands.py +166 -0
- clm/layer4/membrane.py +273 -0
- clm/layer4/navigation.py +50 -0
- clm/layer4/protocol/protocol_entry_python.py +108 -0
- clm/layer4/protocol/python_sync.py +126 -0
- clm/layer4/runner.py +150 -0
- clm/layer4/satori.py +262 -0
- clm/layer4/server/python_sync_client.py +150 -0
- clm/layer4/server/python_sync_server.py +139 -0
- clm/layer4/server/service_api.py +315 -0
- clm/layer4/server/start_servers.py +107 -0
- clm/layer4/server/stop_servers.py +24 -0
- clm/layer4/simulated_optimization_fix.py +0 -0
- clm/layer4/storage.py +463 -0
- clm/layer4/tridb_admin.py +268 -0
- clm/layer4/websocket/test_ws_client.py +104 -0
- clm/layer4/websocket/test_ws_server.py +138 -0
- clm/layer4/websocket/ws_server_local.py +160 -0
- clm/layer5/__init__.py +51 -0
- clm/layer5/async_batch_writer.py +133 -0
- clm/layer5/learning.py +276 -0
- clm/layer5/telemetry_hook.py +107 -0
- clm/layer5/type_lattice.py +238 -0
- clm/py.typed +0 -0
- clm/schemas/__init__.py +652 -0
- clm/schemas/abstract_face_schema.yaml +77 -0
- clm/schemas/cel_schema.yaml +416 -0
- clm/schemas/lifecycle/__init__.py +45 -0
- clm/schemas/lifecycle/models.py +123 -0
- clm/schemas/lifecycle/service.py +364 -0
- clm/schemas/mcard_schema.sql +192 -0
- clm/schemas/mcard_vector_schema.sql +283 -0
- clm/schemas/mlp-context-v1.json +91 -0
- clm_kernel-0.0.0.dist-info/METADATA +121 -0
- clm_kernel-0.0.0.dist-info/RECORD +333 -0
- clm_kernel-0.0.0.dist-info/WHEEL +4 -0
- clm_kernel-0.0.0.dist-info/entry_points.txt +3 -0
- clm_kernel-0.0.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
-- ═══════════════════════════════════════════════════════════════════════════════
|
|
2
|
+
-- MCard Vector Database Schema (mcard_vectors.db)
|
|
3
|
+
-- ═══════════════════════════════════════════════════════════════════════════════
|
|
4
|
+
--
|
|
5
|
+
-- This schema defines the structure for "Secondary Qualities" (Extrinsic Embeddings).
|
|
6
|
+
-- It is separated from the core mcard.db (Monadic Intrinsic Properties) to ensure:
|
|
7
|
+
-- 1. Separation of Concerns (Intrinsic vs Extrinsic)
|
|
8
|
+
-- 2. Linearity (Vectors are observer-dependent and large)
|
|
9
|
+
-- 3. Upgradability (Embedding models change frequently)
|
|
10
|
+
--
|
|
11
|
+
-- See: Monadic Justification for Schema Design.md
|
|
12
|
+
-- ═══════════════════════════════════════════════════════════════════════════════
|
|
13
|
+
|
|
14
|
+
-- ═══════════════════════════════════════════════════════════════════════════════
|
|
15
|
+
-- LAYER 3: VECTOR STORAGE (Semantic Embeddings)
|
|
16
|
+
-- ═══════════════════════════════════════════════════════════════════════════════
|
|
17
|
+
-- Storage for vector embeddings enabling semantic search.
|
|
18
|
+
-- Links to content via hash for content-addressing.
|
|
19
|
+
|
|
20
|
+
-- @table mcard_vector_metadata
|
|
21
|
+
-- @description Metadata for stored embeddings
|
|
22
|
+
-- @column id - Auto-increment primary key
|
|
23
|
+
-- @column hash - FK to card.hash
|
|
24
|
+
-- @column model_name - Embedding model used (e.g., "nomic-embed-text")
|
|
25
|
+
-- @column dimensions - Vector dimensions
|
|
26
|
+
-- @column chunk_index - Index for chunked documents (0 = first/whole)
|
|
27
|
+
-- @column chunk_total - Total chunks for this document
|
|
28
|
+
-- @column chunk_text - Preview text for this chunk
|
|
29
|
+
-- @column created_at - When embedding was created
|
|
30
|
+
CREATE TABLE IF NOT EXISTS mcard_vector_metadata (
|
|
31
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
32
|
+
hash TEXT NOT NULL,
|
|
33
|
+
model_name TEXT NOT NULL,
|
|
34
|
+
dimensions INTEGER NOT NULL,
|
|
35
|
+
chunk_index INTEGER DEFAULT 0,
|
|
36
|
+
chunk_total INTEGER DEFAULT 1,
|
|
37
|
+
chunk_text TEXT,
|
|
38
|
+
created_at TEXT NOT NULL,
|
|
39
|
+
UNIQUE(hash, chunk_index)
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
-- @index idx_vector_metadata_hash
|
|
43
|
+
-- @description Efficient lookup of embeddings by content hash
|
|
44
|
+
CREATE INDEX IF NOT EXISTS idx_vector_metadata_hash
|
|
45
|
+
ON mcard_vector_metadata(hash);
|
|
46
|
+
|
|
47
|
+
-- @table mcard_embeddings
|
|
48
|
+
-- @description Fallback embedding storage when sqlite-vec is unavailable
|
|
49
|
+
-- @column id - Auto-increment primary key
|
|
50
|
+
-- @column metadata_id - FK to mcard_vector_metadata.id
|
|
51
|
+
-- @column embedding - Serialized float32 vector as BLOB
|
|
52
|
+
CREATE TABLE IF NOT EXISTS mcard_embeddings (
|
|
53
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
54
|
+
metadata_id INTEGER NOT NULL,
|
|
55
|
+
embedding BLOB NOT NULL,
|
|
56
|
+
UNIQUE(metadata_id),
|
|
57
|
+
FOREIGN KEY (metadata_id) REFERENCES mcard_vector_metadata(id)
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
-- @virtual_table mcard_fts
|
|
61
|
+
-- @description Full-text search for hybrid retrieval
|
|
62
|
+
-- @note Uses Porter stemming with Unicode support
|
|
63
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS mcard_fts USING fts5(
|
|
64
|
+
hash,
|
|
65
|
+
content,
|
|
66
|
+
tokenize='porter unicode61'
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
-- Note: sqlite-vec virtual table is created dynamically with dimensions:
|
|
70
|
+
-- CREATE VIRTUAL TABLE IF NOT EXISTS mcard_vec USING vec0(
|
|
71
|
+
-- metadata_id INTEGER PRIMARY KEY,
|
|
72
|
+
-- embedding float[${dimensions}]
|
|
73
|
+
-- );
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
-- ═══════════════════════════════════════════════════════════════════════════════
|
|
77
|
+
-- LAYER 4: SEMANTIC VERSIONING (Handle-Vector Bridge)
|
|
78
|
+
-- ═══════════════════════════════════════════════════════════════════════════════
|
|
79
|
+
-- Bridges handles to vector embeddings for semantic version comparison.
|
|
80
|
+
-- Enables measuring semantic drift between document versions.
|
|
81
|
+
|
|
82
|
+
-- @table handle_version_vectors
|
|
83
|
+
-- @description Links handle versions to their semantic embeddings
|
|
84
|
+
-- @column id - Auto-increment primary key
|
|
85
|
+
-- @column handle - FK to handle_registry.handle
|
|
86
|
+
-- @column hash - FK to card.hash (this version)
|
|
87
|
+
-- @column parent_hash - FK to card.hash (previous version)
|
|
88
|
+
-- @column version_order - 0 = current, 1 = previous, etc.
|
|
89
|
+
-- @column is_current - TRUE if this is the current version
|
|
90
|
+
-- @column embedding_id - FK to mcard_vector_metadata.id
|
|
91
|
+
-- @column semantic_delta_from_parent - Cosine similarity to parent [-1, 1]
|
|
92
|
+
-- @column upgrade_type - Classification: 'trivial' | 'minor' | 'major' | 'breaking'
|
|
93
|
+
-- @column created_at - When this version was linked
|
|
94
|
+
CREATE TABLE IF NOT EXISTS handle_version_vectors (
|
|
95
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
96
|
+
handle TEXT NOT NULL,
|
|
97
|
+
hash TEXT NOT NULL,
|
|
98
|
+
parent_hash TEXT,
|
|
99
|
+
version_order INTEGER NOT NULL,
|
|
100
|
+
is_current BOOLEAN DEFAULT FALSE,
|
|
101
|
+
embedding_id INTEGER,
|
|
102
|
+
semantic_delta_from_parent REAL,
|
|
103
|
+
upgrade_type TEXT,
|
|
104
|
+
created_at TEXT NOT NULL,
|
|
105
|
+
UNIQUE(handle, hash),
|
|
106
|
+
FOREIGN KEY (embedding_id) REFERENCES mcard_vector_metadata(id)
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
-- @index idx_hvv_handle
|
|
110
|
+
-- @description Efficient lookup of versions by handle
|
|
111
|
+
CREATE INDEX IF NOT EXISTS idx_hvv_handle
|
|
112
|
+
ON handle_version_vectors(handle);
|
|
113
|
+
|
|
114
|
+
-- @index idx_hvv_hash
|
|
115
|
+
-- @description Efficient lookup of versions by hash
|
|
116
|
+
CREATE INDEX IF NOT EXISTS idx_hvv_hash
|
|
117
|
+
ON handle_version_vectors(hash);
|
|
118
|
+
|
|
119
|
+
-- @index idx_hvv_current
|
|
120
|
+
-- @description Efficient lookup of current versions
|
|
121
|
+
CREATE INDEX IF NOT EXISTS idx_hvv_current
|
|
122
|
+
ON handle_version_vectors(is_current);
|
|
123
|
+
|
|
124
|
+
-- @index idx_hvv_parent
|
|
125
|
+
-- @description Efficient lookup by parent hash
|
|
126
|
+
CREATE INDEX IF NOT EXISTS idx_hvv_parent
|
|
127
|
+
ON handle_version_vectors(parent_hash);
|
|
128
|
+
|
|
129
|
+
-- @table version_similarity_cache
|
|
130
|
+
-- @description Precomputed pairwise similarities for performance
|
|
131
|
+
-- @column id - Auto-increment primary key
|
|
132
|
+
-- @column handle - Handle these versions belong to
|
|
133
|
+
-- @column hash_a - First version hash
|
|
134
|
+
-- @column hash_b - Second version hash
|
|
135
|
+
-- @column similarity_score - Cosine similarity [-1, 1]
|
|
136
|
+
-- @column distance_euclidean - L2 distance [0, ∞)
|
|
137
|
+
-- @column computed_at - When similarity was computed
|
|
138
|
+
CREATE TABLE IF NOT EXISTS version_similarity_cache (
|
|
139
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
140
|
+
handle TEXT NOT NULL,
|
|
141
|
+
hash_a TEXT NOT NULL,
|
|
142
|
+
hash_b TEXT NOT NULL,
|
|
143
|
+
similarity_score REAL NOT NULL,
|
|
144
|
+
distance_euclidean REAL,
|
|
145
|
+
computed_at TEXT NOT NULL,
|
|
146
|
+
UNIQUE(handle, hash_a, hash_b)
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
-- @index idx_vsc_handle
|
|
150
|
+
-- @description Efficient lookup of cached similarities by handle
|
|
151
|
+
CREATE INDEX IF NOT EXISTS idx_vsc_handle
|
|
152
|
+
ON version_similarity_cache(handle);
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
-- ═══════════════════════════════════════════════════════════════════════════════
|
|
156
|
+
-- LAYER 5: KNOWLEDGE GRAPH (GraphRAG)
|
|
157
|
+
-- ═══════════════════════════════════════════════════════════════════════════════
|
|
158
|
+
-- Storage for extracted knowledge graph entities and relationships.
|
|
159
|
+
|
|
160
|
+
-- @table graph_entities
|
|
161
|
+
-- @description Nodes in the knowledge graph
|
|
162
|
+
-- @column id - Auto-increment primary key
|
|
163
|
+
-- @column name - Entity name
|
|
164
|
+
-- @column type - Entity type (e.g., "Person", "Organization")
|
|
165
|
+
-- @column description - Optional description
|
|
166
|
+
-- @column source_hash - FK to card.hash where entity was extracted
|
|
167
|
+
-- @column embedding - Optional entity embedding
|
|
168
|
+
-- @column created_at - When entity was created
|
|
169
|
+
CREATE TABLE IF NOT EXISTS graph_entities (
|
|
170
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
171
|
+
name TEXT NOT NULL,
|
|
172
|
+
type TEXT NOT NULL,
|
|
173
|
+
description TEXT,
|
|
174
|
+
source_hash TEXT NOT NULL,
|
|
175
|
+
embedding BLOB,
|
|
176
|
+
created_at TEXT NOT NULL,
|
|
177
|
+
UNIQUE(name, type, source_hash)
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
-- @index idx_entity_name
|
|
181
|
+
-- @description Efficient entity lookup by name
|
|
182
|
+
CREATE INDEX IF NOT EXISTS idx_entity_name
|
|
183
|
+
ON graph_entities(name);
|
|
184
|
+
|
|
185
|
+
-- @index idx_entity_type
|
|
186
|
+
-- @description Efficient entity lookup by type
|
|
187
|
+
CREATE INDEX IF NOT EXISTS idx_entity_type
|
|
188
|
+
ON graph_entities(type);
|
|
189
|
+
|
|
190
|
+
-- @index idx_entity_source
|
|
191
|
+
-- @description Efficient entity lookup by source document
|
|
192
|
+
CREATE INDEX IF NOT EXISTS idx_entity_source
|
|
193
|
+
ON graph_entities(source_hash);
|
|
194
|
+
|
|
195
|
+
-- @table graph_relationships
|
|
196
|
+
-- @description Edges in the knowledge graph
|
|
197
|
+
-- @column id - Auto-increment primary key
|
|
198
|
+
-- @column source_entity_id - FK to graph_entities.id (from)
|
|
199
|
+
-- @column target_entity_id - FK to graph_entities.id (to)
|
|
200
|
+
-- @column relationship - Relationship type/label
|
|
201
|
+
-- @column description - Optional description
|
|
202
|
+
-- @column weight - Relationship strength
|
|
203
|
+
-- @column source_hash - FK to card.hash where relationship was extracted
|
|
204
|
+
-- @column created_at - When relationship was created
|
|
205
|
+
CREATE TABLE IF NOT EXISTS graph_relationships (
|
|
206
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
207
|
+
source_entity_id INTEGER NOT NULL,
|
|
208
|
+
target_entity_id INTEGER NOT NULL,
|
|
209
|
+
relationship TEXT NOT NULL,
|
|
210
|
+
description TEXT,
|
|
211
|
+
weight REAL DEFAULT 1.0,
|
|
212
|
+
source_hash TEXT NOT NULL,
|
|
213
|
+
created_at TEXT NOT NULL,
|
|
214
|
+
UNIQUE(source_entity_id, target_entity_id, relationship, source_hash),
|
|
215
|
+
FOREIGN KEY (source_entity_id) REFERENCES graph_entities(id),
|
|
216
|
+
FOREIGN KEY (target_entity_id) REFERENCES graph_entities(id)
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
-- @index idx_rel_source
|
|
220
|
+
-- @description Efficient lookup of relationships by source entity
|
|
221
|
+
CREATE INDEX IF NOT EXISTS idx_rel_source
|
|
222
|
+
ON graph_relationships(source_entity_id);
|
|
223
|
+
|
|
224
|
+
-- @index idx_rel_target
|
|
225
|
+
-- @description Efficient lookup of relationships by target entity
|
|
226
|
+
CREATE INDEX IF NOT EXISTS idx_rel_target
|
|
227
|
+
ON graph_relationships(target_entity_id);
|
|
228
|
+
|
|
229
|
+
-- @table graph_communities
|
|
230
|
+
-- @description Hierarchical community summaries (GraphRAG)
|
|
231
|
+
-- @column id - Auto-increment primary key
|
|
232
|
+
-- @column level - Hierarchy level (0 = leaf)
|
|
233
|
+
-- @column title - Community title
|
|
234
|
+
-- @column summary - AI-generated summary
|
|
235
|
+
-- @column embedding - Community embedding
|
|
236
|
+
-- @column member_entity_ids - JSON array of entity IDs
|
|
237
|
+
-- @column parent_community_id - FK to parent community
|
|
238
|
+
-- @column created_at - When community was created
|
|
239
|
+
CREATE TABLE IF NOT EXISTS graph_communities (
|
|
240
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
241
|
+
level INTEGER NOT NULL DEFAULT 0,
|
|
242
|
+
title TEXT,
|
|
243
|
+
summary TEXT NOT NULL,
|
|
244
|
+
embedding BLOB,
|
|
245
|
+
member_entity_ids TEXT,
|
|
246
|
+
parent_community_id INTEGER,
|
|
247
|
+
created_at TEXT NOT NULL,
|
|
248
|
+
FOREIGN KEY (parent_community_id) REFERENCES graph_communities(id)
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
-- @index idx_community_level
|
|
252
|
+
-- @description Efficient lookup of communities by level
|
|
253
|
+
CREATE INDEX IF NOT EXISTS idx_community_level
|
|
254
|
+
ON graph_communities(level);
|
|
255
|
+
|
|
256
|
+
-- @table graph_extractions
|
|
257
|
+
-- @description Tracks which documents have been processed for entity extraction
|
|
258
|
+
-- @column hash - FK to card.hash (primary key)
|
|
259
|
+
-- @column entity_count - Number of entities extracted
|
|
260
|
+
-- @column relationship_count - Number of relationships extracted
|
|
261
|
+
-- @column extracted_at - When extraction was performed
|
|
262
|
+
CREATE TABLE IF NOT EXISTS graph_extractions (
|
|
263
|
+
hash TEXT PRIMARY KEY,
|
|
264
|
+
entity_count INTEGER DEFAULT 0,
|
|
265
|
+
relationship_count INTEGER DEFAULT 0,
|
|
266
|
+
extracted_at TEXT NOT NULL
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
-- ═══════════════════════════════════════════════════════════════════════════════
|
|
270
|
+
-- SCHEMA METADATA (Vector DB)
|
|
271
|
+
-- ═══════════════════════════════════════════════════════════════════════════════
|
|
272
|
+
|
|
273
|
+
-- @table schema_version
|
|
274
|
+
-- @description Tracks schema version for migrations
|
|
275
|
+
CREATE TABLE IF NOT EXISTS vector_schema_version (
|
|
276
|
+
version TEXT PRIMARY KEY,
|
|
277
|
+
applied_at TEXT NOT NULL,
|
|
278
|
+
description TEXT
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
-- Insert current schema version
|
|
282
|
+
INSERT OR IGNORE INTO vector_schema_version (version, applied_at, description)
|
|
283
|
+
VALUES ('1.0.0', datetime('now'), 'Initial MCard Vector Schema');
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://mcard.org/schemas/mlp-context-v1.json",
|
|
4
|
+
"title": "Multi-Language Protocol (MLP) Context Schema",
|
|
5
|
+
"description": "Defines the standardized context block passed to all polyglot runtimes via stdin or env variables in the CLM kernel.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": [
|
|
8
|
+
"context",
|
|
9
|
+
"environment",
|
|
10
|
+
"databases"
|
|
11
|
+
],
|
|
12
|
+
"properties": {
|
|
13
|
+
"context": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"required": [
|
|
16
|
+
"operation",
|
|
17
|
+
"clm_file",
|
|
18
|
+
"a_hash",
|
|
19
|
+
"c_hash"
|
|
20
|
+
],
|
|
21
|
+
"properties": {
|
|
22
|
+
"operation": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "The active function/operation name executing in the CLM."
|
|
25
|
+
},
|
|
26
|
+
"clm_file": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"description": "Absolute filesystem path to the target CLM manifest."
|
|
29
|
+
},
|
|
30
|
+
"a_hash": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"pattern": "^sha256:[a-fA-F0-9]{64}$",
|
|
33
|
+
"description": "Cryptographic SHA-256 hash of the Abstract Specification (A-MCard)."
|
|
34
|
+
},
|
|
35
|
+
"c_hash": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"pattern": "^sha256:[a-fA-F0-9]{64}$",
|
|
38
|
+
"description": "Cryptographic SHA-256 hash of the Concrete Implementation (C-MCard)."
|
|
39
|
+
},
|
|
40
|
+
"payload": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"description": "Optional payload input parameter passed to the active process."
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"environment": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"required": [
|
|
49
|
+
"CLM_ROOT",
|
|
50
|
+
"g_time"
|
|
51
|
+
],
|
|
52
|
+
"properties": {
|
|
53
|
+
"CLM_ROOT": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"description": "Absolute path to the active clm/ repository directory."
|
|
56
|
+
},
|
|
57
|
+
"PROJECT_ROOT": {
|
|
58
|
+
"type": "string",
|
|
59
|
+
"description": "Absolute path to the parent MCard_TDD/ directory."
|
|
60
|
+
},
|
|
61
|
+
"g_time": {
|
|
62
|
+
"type": "string",
|
|
63
|
+
"pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})$",
|
|
64
|
+
"description": "Standardized ISO 8601 global evaluation timestamp."
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"databases": {
|
|
69
|
+
"type": "object",
|
|
70
|
+
"required": [
|
|
71
|
+
"identity_db",
|
|
72
|
+
"content_db",
|
|
73
|
+
"execution_log_db"
|
|
74
|
+
],
|
|
75
|
+
"properties": {
|
|
76
|
+
"identity_db": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"description": "Absolute path to the SQLite identity_space database."
|
|
79
|
+
},
|
|
80
|
+
"content_db": {
|
|
81
|
+
"type": "string",
|
|
82
|
+
"description": "Absolute path to the SQLite content_memory database."
|
|
83
|
+
},
|
|
84
|
+
"execution_log_db": {
|
|
85
|
+
"type": "string",
|
|
86
|
+
"description": "Absolute path to the SQLite execution_log database."
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: clm-kernel
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Card Lifecycle Manager (CLM) Kernel — Sovereign Functional Agentic Operating System
|
|
5
|
+
Author: GovTech Digital Identity & Autonomous Systems
|
|
6
|
+
License: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: MacOS
|
|
12
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Software Development :: Interpreters
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Requires-Dist: aiohttp>=3.9.0
|
|
21
|
+
Requires-Dist: aiosqlite>=0.17.0
|
|
22
|
+
Requires-Dist: base58>=2.1.1
|
|
23
|
+
Requires-Dist: blake3>=0.4.0
|
|
24
|
+
Requires-Dist: chardet>=5.1.0
|
|
25
|
+
Requires-Dist: cryptography>=44.0.0
|
|
26
|
+
Requires-Dist: duckdb>=1.0.0
|
|
27
|
+
Requires-Dist: fastapi>=0.100.0
|
|
28
|
+
Requires-Dist: httpx>=0.25.0
|
|
29
|
+
Requires-Dist: jsonschema>=4.26.0
|
|
30
|
+
Requires-Dist: networkx>=3.0
|
|
31
|
+
Requires-Dist: pillow>=10.0.0
|
|
32
|
+
Requires-Dist: pydantic>=2.0.0
|
|
33
|
+
Requires-Dist: python-dateutil>=2.9.0
|
|
34
|
+
Requires-Dist: python-dotenv>=1.1.0
|
|
35
|
+
Requires-Dist: python-multipart>=0.0.9
|
|
36
|
+
Requires-Dist: pyyaml>=6.0
|
|
37
|
+
Requires-Dist: reportlab>=4.0.0
|
|
38
|
+
Requires-Dist: requests>=2.28.0
|
|
39
|
+
Requires-Dist: result>=0.17.0
|
|
40
|
+
Requires-Dist: scipy>=1.14.0
|
|
41
|
+
Requires-Dist: sqlalchemy>=1.4.0
|
|
42
|
+
Requires-Dist: typing-extensions>=4.5.0
|
|
43
|
+
Requires-Dist: uvicorn>=0.20.0
|
|
44
|
+
Requires-Dist: websockets>=12.0
|
|
45
|
+
Provides-Extra: dev
|
|
46
|
+
Requires-Dist: build>=1.0.0; extra == 'dev'
|
|
47
|
+
Requires-Dist: hatchling>=1.20.0; extra == 'dev'
|
|
48
|
+
Requires-Dist: hypothesis>=6.100.0; extra == 'dev'
|
|
49
|
+
Requires-Dist: mypy>=1.10.0; extra == 'dev'
|
|
50
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
51
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
|
|
52
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
53
|
+
Requires-Dist: ruff>=0.4.0; extra == 'dev'
|
|
54
|
+
Requires-Dist: twine>=5.0.0; extra == 'dev'
|
|
55
|
+
Provides-Extra: native
|
|
56
|
+
Description-Content-Type: text/markdown
|
|
57
|
+
|
|
58
|
+
# clm-kernel
|
|
59
|
+
|
|
60
|
+
Card Lifecycle Manager (CLM) Kernel — Sovereign Functional Agentic Operating System.
|
|
61
|
+
|
|
62
|
+
`clm-kernel` is the foundational Python implementation of the Cubical Logic Model (CLM), providing a stratified 5-layer architecture for sovereign, functional, deterministically auditable agentic execution.
|
|
63
|
+
|
|
64
|
+
## Architectural Layers
|
|
65
|
+
|
|
66
|
+
- **Layer 0: Cryptographic Substrate & Storage**
|
|
67
|
+
- Content-addressable storage via BLAKE3 hashing
|
|
68
|
+
- Merkle DAG tree synthesis and verification
|
|
69
|
+
- TriDatabase manager and multi-agent Vector Clocks
|
|
70
|
+
- **Layer 1: Type Lattice & Schema Model**
|
|
71
|
+
- Pydantic-backed invariant validation
|
|
72
|
+
- Deterministic AST transformations and MCard schemas
|
|
73
|
+
- **Layer 2: Reactive Graph & CPN-VM**
|
|
74
|
+
- Coloured Petri Net (CPN) virtual machine
|
|
75
|
+
- Token passing, transition firings, and concurrency invariants
|
|
76
|
+
- **Layer 3: Cordis Spatiotemporal Actor Model**
|
|
77
|
+
- Effect isolation, savepoints (`SavepointGuard`), and cleanup scopes (`DisposableList`)
|
|
78
|
+
- Monadic execution with rollback guarantees
|
|
79
|
+
- **Layer 4: Sovereign Execution & Gateway**
|
|
80
|
+
- Full CLI (`clm`, `clmEval`)
|
|
81
|
+
- Triad Gateway and Model Context Protocol (MCP) server integration
|
|
82
|
+
|
|
83
|
+
## Installation
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install clm-kernel
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## CLI Usage
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Display CLI help
|
|
93
|
+
clm --help
|
|
94
|
+
|
|
95
|
+
# Evaluate an action or workflow manifest
|
|
96
|
+
clm evaluate --file workflow.yaml
|
|
97
|
+
|
|
98
|
+
# Initialize TriDatabase storage
|
|
99
|
+
clm init-tridb --path ./data
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Python API Quick Start
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from clm.layer0.merkle import MerkleTree
|
|
106
|
+
from clm.layer4 import SovereignExecutor
|
|
107
|
+
|
|
108
|
+
# Create and verify Merkle DAG
|
|
109
|
+
tree = MerkleTree()
|
|
110
|
+
tree.insert("card-1", b"payload data")
|
|
111
|
+
root_hash = tree.compute_root()
|
|
112
|
+
print(f"Merkle Root: {root_hash}")
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## License
|
|
116
|
+
|
|
117
|
+
MIT License. See [LICENSE](https://github.com/xlp0/CLM/blob/main/LICENSE) for details.
|
|
118
|
+
|
|
119
|
+
## Monorepo & Documentation
|
|
120
|
+
|
|
121
|
+
Source code, formal proofs, and multi-language kernels (Rust, JavaScript/TypeScript, WASM) are maintained in the main [CLM Repository](https://github.com/xlp0/CLM).
|